enhanceApp.js 解决中文路径问题出现 开发环境导航栏点击后直接跳转到生产环境页面
duktig666 opened this issue · comments
RenShiwei commented
在你的仓库中的话可以 迭代一下
.vuepress/enhanceApp.js
export default (ctx) => { const routes = ctx.router.getRoutes() ctx.router.beforeEach((to, from, next) => { // 解决decode后反复重定向的问题 const route = routes.find((v) => v.regex.test(to.path)) // .html有重定向路由,无需特殊处理 if (/\.html$/.test(to.path)) { return next() } // 不特殊处理 非通配符的 没有重定向的路由 if (route && route.path !== '*' && !route.redirect) { return next() } // 解决中文标签/分类路由无法被正确加载的问题 if (decodeURIComponent(to.path) !== to.path) { return next( Object.assign({}, to, { path: decodeURIComponent(to.path), fullPath: decodeURIComponent(to.fullPath) }) ) } next() }) // 临时解决,防止内部调用钩子再处理 ctx.router.beforeEach = () => { return } }
经过测试已经成功解决了这个问题
Originally posted by @duktig666 in #395 (comment)
sugar commented
不太清楚标题描述的问题,给个demo演示一下?
RenShiwei commented
问题
信息
版本:1.6.10
开发环境:win10
生产环境:github pages
仓库地址:https://github.com/duktig666/duktig666.github.io
不太清楚标题描述的问题,给个demo演示一下?
@ATQQ
RenShiwei commented
Reco commented
没有复现你所描述的问题呢