怎么将vue项目中地址上的#号去掉

作者: web 发布时间: 2022-04-12 浏览: 1011 次 编辑

这种写法的优点是不用后端配置任何东西,在上传到服务器后也不会出现屏幕空白和404的情况
router代码

const router = new Router({
  mode: 'history',
  routes: [......]
})


<template>
  <div id="app">
    <router-view v-if="isRouterShow"></router-view>
  </div>
</template>


<script>
  export default {
    name: "App",
    provide() {
      return {
        reload: this.reload,
      };
    },
    data() {
      return {
        isRouterShow: true,
      };
    },
    methods:{
     async reload() {
              this.isRouterShow = false;
              await this.$nextTick();
              this.isRouterShow = true;
     }
    }
  };
</script>