<template>
  <div>
    <router-view :key="key" v-if="isRouterAlive"></router-view>
  </div>
</template>

<script>
export default {
  name: 'AppMain',
  provide() { // 注册一个方法
    return {
      reload: this.reload
    }
  },
  data() {
    return {
      isRouterAlive: true // 局部刷新
    }
  },
  computed: {
    key() {
      return this.$route.fullPath
    }
  },
  methods: {
    back() {
      this.$router.back()
    },
    // 全局局部刷新
    reload() {
      this.isRouterAlive = false
      this.$nextTick(() => {
        this.isRouterAlive = true
      })
    }
  },
  mounted() {
  }
}
</script>

<style type="text/scss" lang="scss" scoped>
</style>
