简单的MPVUE遮罩层

HTML

  <div id="rightBlock" @click="showList" v-if="show">//外部也绑定了事件,可以实现点击整个界面,将弹框收回
    <div id="personalInfo">
        <img :src="userInfo.avatarUrl" alt="">
    </div>
  </div>

设置一个button绑定弹框事件

  <button @click="showList">显示</button>

JS

data里设置:

    data () {
return {
  userInfo: {},
  show: false //用来控制显示与否的变量
}
  }
methods:{
showList () {
  this.show = !this.show
}
}

CSS

 #rightBlock{
display: block;
float: right;
width: 750rpx;
height: 100%;
z-index: 12;
position: absolute;
background:rgba(0,0,0,0.4);
  }
  #personalInfo{
display: block;
float: right;
width: 300rpx;
position: relative;
height: 100%;
background:#FFFFFF;
  }

猜你喜欢

转载自blog.csdn.net/qq_30304751/article/details/81349326
今日推荐