父组件
<van-button type="primary" @click size="large" @click="show()"> 显示组件
</van-button><child v-if="show" @closetip="show()" :arr="fathermsg"></child>export defanlt{
data(){
return{
show:false,
fathermsg:""
}
},
methods(){
show(){
this.show=!this.show
},
}
}
子组件
<template> <van-popup v-model="myshow" closeable :duration='0.3'
@click-overlay='close' @click='close'><van-list v-model="loading" :finished="finished" finished-text="没有更多了"> <van-cell v-for="item in dataarr" /></van-list> </van-popup></template>export default {
name:'getOrder',
props:["arr"],//父组件传来的值
data(){
return{
myshow:true,//popup的显示,在组件中,默认是显示,不用父组件传值
dataarr:this.arr,
}
},
methods: {
close(){
this.$emit("closeTip",false)//把关闭信息传递给父组件
}
}
}
网友评论