The parent component passes the data of the asynchronous request to the child component, and the child component prints empty

Encountered a problem like this,

// 父组件

<nav-head :projeList="projeList" @getMessage="getmessagefromChild"></nav-head>

传递的projeList ,是从created函数中执行获取到的
// 子组件

props:["projeList"],

created() {
  	console.log("测试",this.projeList)
},

The interface has data, but the subcomponents just can't get it.

solve:

// 父组件 

<div v-if="projeList.length>0">
	<nav-head :projeList="projeList" @getMessage="getmessagefromChild"></nav-head>
</div>

在父组件上加一层div,等projeList有数据之后,再去加载子组件。

Guess you like

Origin blog.csdn.net/YZ_ZZZ24/article/details/122493680