我有一个父组件,在其上设置了数据属性:
created() {
carModels()
.then(x => {
this.carModels= [{ value: null, text: 'None' }].concat(x);
});
},
carModels
是传递给子组件的道具。
目前,在上述代码中设置道具之前,该道具会传递给孩子。我一直在寻找解决方案,但我缺少一些东西……我应该如何等待它,或者在加载子项之后对其进行更新?大概promise
会做到这一点?
答案 0 :(得分:0)
按照@Niklesh Raut的评论中的指示,我使用孩子身上的手表解决了该问题:
watch: {
carModels: function (carModels) {
console.log(carModels);
}
},