1.主组件app.vue:
<top @display="changePage"></top>
<router-view></router-view>
<rightBar v-show="dis"></rightBar>
<foot1></foot1>
2.头部组件top.vue:(头部元素中点击事件触发父组件app.vue中的display;@click="showTool")
methods: {
showTool(){
this.$emit('display');
}
}
3.弹窗组件rightbar.vue
4.问题:怎么实现在弹窗组件中的button点击按钮关闭弹窗呢(或者更好的其他方法也可以)?
app.vue
rightbar.vue
这个的执行原理就是,利用父组件,触发子组件的函数,然后隐藏子组件,你这个的前提就是保证<top @display="changePage"></top>这个能触发父组件的changePage这个函数,这个你已经实现了,我就不多写了