嗨,我尝试像本教程一样在父母和孩子之间传递数据: https://www.youtube.com/watch?v=PPmg7ntQjzc
常规HTML输入可以正常工作(就像本教程中一样)。
但是,验证文本字段或文本区域无效。 (起初看起来还不错。当我开始输入文字时,会提示错误)
我在做什么错了?
//子HTML
<input
type="text"
placeholder="regular child"
:value="valueRegularChild"
@input="inputRegularChild"
>
<p>{{ regularInputValue }}</p>
<v-textarea
type="text"
placeholder="vuetify child"
:value="valueVuetifyChild"
@input="inputVuetifyChild"
></v-textarea>
<p>{{ vuetifyInputValue }}</p>
//子-方法
inputVuetifyChild($event) {
this.vuetifyInputValue = $event.target.value;
this.$emit('msgVuetify', this.vuetifyInputValue);
},
inputRegularChild($event) {
this.regularInputValue = $event.target.value;
this.$emit('msgRegular', this.regularInputValue);
},
//父HTML
<child-component
:valueVuetifyChild="insideParentVuetify"
:valueRegularChild="insideParentRegular"
@msgVuetify="insideParentVuetify = $event"
@msgRegular="insideParentRegular = $event"
>
<child-component>
一切都一样。
常规作品,Vuetify不要
consol日志错误说:
TypeError:无法读取未定义的属性“值”
预先感谢
答案 0 :(得分:-1)
我认为v-model
应该比:value
更好,但是还没有时间测试ist。
//子HTML
<input
type="text"
placeholder="regular child"
v-model="valueRegularChild"
@input="inputRegularChild"
>
<p>{{ regularInputValue }}</p>
<v-textarea
type="text"
placeholder="vuetify child"
v-model="valueVuetifyChild"
@input="inputVuetifyChild"
></v-textarea>
<p>{{ vuetifyInputValue }}</p>
//子-方法
inputVuetifyChild($event) {
this.$emit('msgVuetify', this.vuetifyInputValue);
},
inputRegularChild($event) {
this.$emit('msgRegular', this.regularInputValue);
},
//父HTML
<child-component
:valueVuetifyChild="insideParentVuetify"
:valueRegularChild="insideParentRegular"
@msgVuetify="insideParentVuetify = $event"
@msgRegular="insideParentRegular = $event"
>
<child-component>