我对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);
}
}
});
Run Code Online (Sandbox Code Playgroud)
我不知道我哪里出错了,尽管我尝试了文档,我仍然遇到数据如何绑定和更新的麻烦.
我正在尝试将 UTC 日期字符串DateTime解析为本地时间,然后将其解析为本地时间,但是我在将其转换为本地时间时遇到了麻烦。在英国,它应该是加一,但是当我打印时.isUtc它返回为假。
这就是我现在所拥有的:
print(widget.asset.purchaseDate);
DateTime temp = DateTime.parse(widget.asset.purchaseDate);
print(temp.toLocal());
Run Code Online (Sandbox Code Playgroud)
I/flutter (5434): 2020-05-07 21:29:00
I/flutter (5434): 2020-05-07 21:29:00.000
Run Code Online (Sandbox Code Playgroud)