父组件
<index v-if="show1" :rentlists="rentlists"></index>
js
components: {
index
},
return{
show1:false,
}
created(){
const db = wx.cloud.database()
db.collection('myRent').where({
type: 'info'
}).get({
success: function(res) {
// 输出 [{ "title": "The Catcher in the Rye", ... }]
this.rentlists=res.data;
// console.log(res.data) //能打印数据
this.show1=true; //但此时这里不生效?
}
})
},
子组件
props:{
rentlists:Array,
default:"" //参数默认
},
mounted(){
console.log(this.rentlists) //undefine?
}
接收不到数据?
请问为什么父传子接收不到数据?父组件能接收到数据库的数据, 但那个v-if却也不生效??
这是父(app.vue)-子(父)(在此请求的数据)->子组件