Father.vue
<template>
<view>
<view @click="show">我是父组件按钮</view>
<child :isShow.sync="isShow" v-if="isShow"></child>
</view>
</template>
<script>
import child from "./child.vue"
export default{
data(){
return{
isShow:false
}
},
components:{
child
},
methods:{
show(){
this.isShow=true;
}
}
}
</script>
child.vue
<template>
<view>
我是子页面
<view @click="upIsShow">我是子组件按钮</view>
</view>
</template>
<script>
export default{
methods:{
upIsShow(){
this.$emit("update:isShow",false);
}
}
}
</script>
原文:https://www.cnblogs.com/joesmile/p/13019525.html