From e156aafcd4fba13d2d6143b12d74828ce5afe92f Mon Sep 17 00:00:00 2001 From: liyang <1711467488@qq.com> Date: Wed, 6 Jun 2018 12:55:28 +0800 Subject: [PATCH] no message Former-commit-id: 6c80c45adf2541bf0956803ff39949bbc6ec7cf4 Former-commit-id: a771e6e5a312afbfd5f591990fcced7851cc32eb Former-commit-id: cfe2dadb617e29d7ba9c6a4484a5426d47962b8f --- src/router/index.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/router/index.js b/src/router/index.js index 9a920a94..faa3af01 100755 --- a/src/router/index.js +++ b/src/router/index.js @@ -11,18 +11,17 @@ console.log(pathPosix) Vue.use(VueRouter) -const path2Posix = pathString => pathString.split(pathPosix.sep).join('/') +const win2posix = pathString => pathString.split('\\').join('/') const routesMaker = ({publicPath, namePrefix, req}) => { return req.keys().map(req).map(page => { // 每个文件的路径 - const pagePath = pathPosix.dirname(page.default.__file) + const pagePath = pathPosix.dirname(win2posix(page.default.__file)) console.log('pagePath', pagePath) - // 每个文件的路径 => posix 风格 - const pagePathPosix = path2Posix(pagePath) - console.log('pagePathPosix', pagePathPosix) // 路由中使用的路径 - const path = pagePathPosix.replace(publicPath, '').replace(new RegExp(`${pathPosix.sep}page${pathPosix.sep}`, 'g'), pathPosix.sep) + const path = pagePath + .replace(win2posix(publicPath), '') + .replace(new RegExp(`${pathPosix.sep}page${pathPosix.sep}`, 'g'), pathPosix.sep) console.log('path', path) const name = namePrefix + path.split(pathPosix.sep).join('-').replace(/-page-/g, '-') return {