1. publicPath
应用运行起来后所在的的根目录。 举例:
//vue.config.js
const { defineConfig } = require("@vue/cli-service");
module.exports = defineConfig({
...
publicPath: "/mypublicpath/",
...
});
//router/index.js
const routes = [
...
{
path: "/admin",
name: "admin",
component: Admin,
//子路由的path 如果前面写'/'将会定位到根路径
children: [
{
path: "index",
component: Index,
},
...
],
},
];
如果访问到Admin下的Index组件时,浏览器url将会是
http://localhost:8080/mypublicpath/#/admin/index
-----------------------|---------------|----------------
WebApp 运行端口号 |...publicPath...|项目内vue router