vuejs / docs-next-zh-cn

:cn: Chinese translation for v3.vuejs.org
https://v3.cn.vuejs.org
MIT License
950 stars 849 forks source link

bug: #780

Closed sanmuw closed 3 years ago

sanmuw commented 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"> })

为何 value 写了一个定值 <input type="text" :value="modelValue" @input="emitValue"> 只会修改一次