怎么在进入某个页面时,弹出公告,且只显示一次

首先一般这种弹出公告都会设为一个单独文件,具体方法不在多说,主要说一下如何进入弹出且只显示一次。

<template>
  <div class="rule" v-if="showPopupintegral">
    <el-dialog  
      :visible.sync="centerDialogVisible1" 
      center>
       
    </el-dialog>
  </div>
</template>
<script>
export default {
  data () {
    return {
      centerDialogVisible1:true,
      showPopupintegral:false,
    }
  },
  created () {
    // 第一次出现弹窗且根据localStorage只显示一次
    if(!localStorage.getItem("showPopupintegral")){
      this.showPopupintegral = true
    }
  },
  methods: {
    // 关闭弹窗时调用的函数
    hideWelDialo(){
      this.showPopupintegral= false
      localStorage.setItem("showPopupintegral", "true");
    },
  },
}
</script>

就是这些了,欢迎交流和指正。

猜你喜欢

转载自www.cnblogs.com/wzfwaf/p/11280160.html
今日推荐