vue刷新页面reload

hxshxs123321 2019-10-23 10:47:53
reload刷新页面:data数据中dialog控制模态框的显示与隐藏,在执行点击事件后,模态框关闭。reload刷新页面时,模态框会显示。想让模态框不再显示,如何解决
...全文
900 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
hxshxs123321 2019-10-23
  • 打赏
  • 举报
回复
解决了, 我用的方法是在app.vue页面新给一个数据,控制是不是刷新,然后传到需要的页面 (isShow)
<template>
    <div id="app">
        <router-view v-if="isRouterAlive" :isShow="isShow"></router-view>
    </div>
</template>

<script>
    export default {
        name: "App",
        provide () {
            return {
                reload: this.reload
            }
        },
        data() {
            return {
                isRouterAlive: true,
                isShow: true
            }
        },
        methods: {
            // 刷新当前页
            reload:function () {
                this.isRouterAlive = false;
                this.$nextTick(function(){
                    this.isRouterAlive = true;
                    this.isShow =  false;
                })
            },
        }
    };
</script>
 mounted: function () {
            if(this.isShow == false) {
                this.dialogGuidelines = false;(控制模态库的显示 与 隐藏)
            } else {
                this.dialogGuidelines = true;
            }
程序博 2019-10-23
  • 打赏
  • 举报
回复
可以把控制显示隐藏的参数存在localStorage中,当刷新页面的话再mounted里取值做判断