1.组件中使用控制显示与隐藏
1.首先来到父组件中
<VersionWindow :visible.sync="visible" @renew="handleRenew"></VersionWindow>
data中声明
visible: true
2.然后是子组件中接受数据
<view class="win-dialog" v-if="visible">
props: {
visible:{
type: Boolean,
default:false
}
},
watch: {
visible: function(val) {
if(val) {
this.handleInit();
}
}
3.子组件更新数据
handleClosure() {
this.$emit('update:visible',false)
},