Closed sanmuw closed 3 years ago
app.component('my-component', { props: { modelValue: String, modelModifiers: { default: () => ({}) } }, emits: ['update:modelValue'], methods: { emitValue(e) { let value = e.target.value if (this.modelModifiers.capitalize) { value = value.charAt(0).toUpperCase() + value.slice(1) }
**value = 'sanmu'** this.$emit('update:modelValue', value) }
}, template: <input type="text" :value="modelValue" @input="emitValue"> })
<input type="text" :value="modelValue" @input="emitValue">
为何 value 写了一个定值 <input type="text" :value="modelValue" @input="emitValue"> 只会修改一次
app.component('my-component', { props: { modelValue: String, modelModifiers: { default: () => ({}) } }, emits: ['update:modelValue'], methods: { emitValue(e) { let value = e.target.value if (this.modelModifiers.capitalize) { value = value.charAt(0).toUpperCase() + value.slice(1) }
}, template:
<input type="text" :value="modelValue" @input="emitValue">
})为何 value 写了一个定值 <input type="text" :value="modelValue" @input="emitValue"> 只会修改一次