下面是我的一段代码:
$(function () {
var vm = new Vue({
el: '#app',
data: {
myObject : {
id: "",
_class : "",
contentType : "TEXT",
textValue : "",
},
selected_language : "ENGLISH",
}我想找到一种用textValue中的内容填充selected_language属性的方法。这意味着我的对象看起来像:
myObject : {
id: "",
_class : "",
contentType : "TEXT",
textValue : "ENGLISH",
}谢谢你提前帮忙,我被困住了
发布于 2017-07-20 06:57:40
是的,您可以在Vue实例中使用this访问this属性,
this.myObject.textValue = this.selected_language如果要在应用程序挂载时自动更新data,请使用created钩子。
var vm = new Vue({
el: '#app',
data: {
myObject : {
id: "",
_class : "",
contentType : "TEXT",
textValue : "",
},
selected_language : "ENGLISH",
},
created: function(){
this.myObject.textValue = this.selected_language
}
})https://stackoverflow.com/questions/45207226
复制相似问题