【发布时间】:2018-06-08 04:15:04
【问题描述】:
vuejs 绑定数据的方式有问题。我有一个父 Vue.component 来处理我的表单布局,我有一个子 vue.component 来处理不同的输入组。当我将来提交表单时,我无法从子组件获取数据以与父组件同步。
我目前有这样的文件:
var title = "";
Vue.component('create_new_entry', {
template: '<div><div class="row"><h1 v-on:click="test()">{{title}}</h1><div class="col-md-12"><section_title></section_title></div></div></div>',
data : function() {
return {
title: title
};
},
});
Vue.component('section_title', {
template: '<div><h1 v-on:click="test()">{{title}}</h1><input type="text" class="form-control" v-model="title"></div>',
data : function() {
return {
title: title
};
},
methods : {
test: function() {
console.log(this);
}
}
});
我不确定我哪里出错了,尽管我尝试查看文档,但我仍然无法解决如何绑定和更新数据。
【问题讨论】:
标签: javascript vue.js vuejs2 vue-component