mounted: function(){
this.$http.get('js/common1.json').then((response) => {
console.log(1);
vm.$data.imgS=response.data;
});
}
computed: {
filteredStyle: function () {
console.log(2);
console.log(this.imgS);
return this.imgS;
}
}
运行后先是打印2,再打印出1,怎么能够先传递数据,在运行计算里的
用watch替换 computed
https://cn.vuejs.org/v2/guide/computed.html#观察-Watchers