我在子组件中:
props: {
selector_config_data: {
type: Array,
required: true
}
},
...
mounted(){
// 这里使用到了`selector_config_data`, 去初始化数据
}
但是我程序报错,说selector_config_data
未定义。
请问如果在mounted()
生命周期方法执行的时候selector_config_data
还没有传递过来的话,我应该怎么才能在保证props传递完成后再进行初始化数据的操作呢?
首先,你要确定 props 已经成功传递,然后在生命周期中使用 this.selector_config_data 即可获得