• vue3的组件v-model初探1


    父组件:

    <template>
      <div class="about">
          <v-input v-model="inp" type="text" />
      </div>
    </template>
    <script lang="ts">
    import { defineComponent, ref } from 'vue'
    import vInput from '@/components/vInput.vue'
    export default defineComponent({
      components: { vInput },
      setup() {
        const inp = ref('111')
        return { inp }
      }
    })
    </script>

    子组件:

    <template>
     <div>
      <input
      :value="val"
      @input="updateInput"
      >
      <div>{{ modelValue }}---{{ val }}</div>
     </div>
    </template>
    <script lang='ts'>
    import { defineComponent, ref } from 'vue'
    export default defineComponent({
      name: 'vInput',
      props: {
        modelValue: String
      },
      setup(props, context) {
        const val = ref(props.modelValue || '')
        const updateInput = (e: KeyboardEvent) => {
          val.value = (e.target as HTMLInputElement).value
          // context.emit('update:modelValue', (e.target as HTMLInputElement).value)
          context.emit('update:modelValue', val.value)
        }
        return {
          val,
          updateInput
        }
      }
    })
    </script>
  • 相关阅读:
    HDU
    稀疏表(ST / Sparse Table)
    HDU
    HDU
    树状数组
    用 BitArray 来编写埃拉托斯特尼筛法
    BitArray 内置是逆序存储, 因此要自行实现正序输出
    位运算,位移,窗体
    按位运算,窗体程序,And,Or,Xor
    基数排序
  • 原文地址:https://www.cnblogs.com/shine-lovely/p/14713157.html
Copyright © 2020-2023  润新知