zhanghua
2024-09-14 46e5592169f0045fcb40d175c21ea3a1e9aeb593
src/App.vue
@@ -1,11 +1,36 @@
<template>
  <div id="app">
    <router-view />
  </div>
    <div id="app">
        <router-view v-if="isRouterAlive" />
    </div>
</template>
<script>
export default {
  name: 'App'
    name: 'App',
    provide() {
        return {
            reload: this.reload
        }
    },
    data() {
        return {
            isRouterAlive: true
        }
    },
    mounted() {
        // 关闭浏览器窗口的时候清空浏览器缓存在localStorage的数据
        window.onbeforeunload = function (e) {
            var storage = window.localStorage;
            storage.clear()
        }
    },
    methods: {
        reload() {
            this.isRouterAlive = false
            this.$nextTick(function () {
                this.isRouterAlive = true
            })
        }
    }
}
</script>