现在我的页面上有个 select
<select type="text" class="form-control" v-bind="chooseItem" v-on:change="changeApp($event.target.value)">
<option value="" selected="selected">-- 应用来源 --</option>
<option v-for="item in channelList" :value="item.id" v-text="item.name"></option>
</select>
我绑定了一个 chooseItem
data 为 chooseItem:{},
然后我的 methods 里有两个方法
add: function () {
this.editLayer.display = true;
// this.chooseItem = {};
// this.chooseItem.app = "";
},
changeApp: function(val){
this.$set(this.chooseItem,'app',val)
}
add 方法调用后会展示这个选择框
我写了个 computed
computed : {
productList:function(){
if(app == '**') {
return this.products[0]
}else if (app == '***') {
return this.products[1]
}else {
return {}
}
}
},
我发现如果我注释掉 methods 里的this.chooseItem.app = "";时,我的 computed 才会随着 select 的切换改变值,不加注释的话 computed 就毫无反应,不过这是什么原因呢?难道是这行代码使 chooseItem.app 变成了非响应式属性嘛?