当前导航到任何不存在的URL,例如:
localhost:3000/abc/cba
将使用以下URL加载主页:
localhost:3000/abc/cba#/
应用程序内部的进一步导航将继续,添加不存在的路径,例如:
localhost:3000/abc/cba#/thisPathExist
我当前的路由器配置基本上是开箱即用的
import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
export default new Router({
mode: 'hash',
base: process.env.BASE_URL,
routes: [
{
path: '/',
name: 'home',
component: () => import(/* webpackChunkName: 'helper' */ './home.route.vue')
},
{
path: '/thisPathExist',
name: 'thisPathExist',
component: () => import(/* webpackChunkName: 'thisPathExist' */ './thisPathExist.vue')
},
]
})
我可以想象任何人都可以收听hashchange,然后通过删除#
之前的URL剩余部分来“标准化” URL,但是我想知道是否还有另一种方式,甚至是{{ 1}}处理此类情况