父组件向子组件传递参数
子组件使用props获取
但是当子组件中代码异步的时候,可能会出现mounted中取不到传递过来的参数的情况。
解决方式:子组件添加监听,如下:
export default { props: ['item'], data () { return { } }, watch:{ item(newValue,oldValue){ console.log(newValue); } } }