我在VueJs2(CLI 3)版本中遇到这个奇怪的问题,那就是Vue会自动从URL中删除父路径。我在route.js文件中有以下路由import Home from "../views/Home";import Login from "../views/Login";const router = [ { path: '/wh', component: { template: '<router-view></router-view>' }, children: [ { path: "/home", name: "home", component: Home }, { path: "/login", name: "login", component: Login }, ], },];export default router;这是我的router.js文件import Vue from "vue";import Router from "vue-router";import routes from './routes'Vue.use(Router);const router = new Router({ mode: 'history', routes: routes, scrollBehavior(to, from, savedPosition) { return {x: 0, y: 0} }});我的main.js包含路由器import App from "./App.vue";import router from "./router/router";import store from "./store/store";new Vue({ store, router, render: h => h(App)}).$mount("#app");还有我的vue.config.jsmodule.exports = { devServer: { proxy: "http://my.app.test" }, outputDir: "public/assets/myApp/app/", filenameHashing: true, runtimeCompiler: true, productionSourceMap: true,};问题出在后面。/wh网址参数中总是缺少。我单击的内容或自动重定向到登录页面的内容/wh均丢失,并且我的应用程序正常运行。我已经尝试设置publicPath: '/wh',vue.config.js并且一切工作都与现在相同。那么,如何正确配置我的路由,这样我才能/wh在我的URL中看到其他子路径之前的内容?如果您需要任何其他信息,请告诉我,我会提供。谢谢!
添加回答
举报
0/150
提交
取消