这种写法的优点是不用后端配置任何东西,在上传到服务器后也不会出现屏幕空白和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>