首先一般這種彈出公告都會設為一個單獨文件,具體方法不在多說,主要說一下如何進入彈出且只顯示一次。
<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>
就是這些了,歡迎交流和指正。