如何等待父母的道具

时间:2019-10-21 10:01:54

标签: vue.js

我有一个父组件,在其上设置了数据属性:

created() {
      carModels()
        .then(x => {
          this.carModels= [{ value: null, text: 'None' }].concat(x);
        });  
    },

carModels是传递给子组件的道具。 目前,在上述代码中设置道具之前,该道具会传递给孩子。我一直在寻找解决方案,但我缺少一些东西……我应该如何等待它,或者在加载子项之后对其进行更新?大概promise会做到这一点?

1 个答案:

答案 0 :(得分:0)

按照@Niklesh Raut的评论中的指示,我使用孩子身上的手表解决了该问题:

watch: {
      carModels: function (carModels) {
        console.log(carModels);
      }
    },
相关问题