// 动态获取路由列表
axios.get(BASE_URL + "/api-backend/route/list").then(res => {
let data = res.data.data;
data.forEach(route => {
let config = {
name: route.name,
path: route.path
};
// the config.path is not null or undefined but the browser report a error
// Error: [vue-router] "path" is required in a route configuration.
// the error maybe in a function named addRouteRecord
/**
var path = route.path;
var name = route.name;
if (process.env.NODE_ENV !== 'production') {
// this line maybe exists a logic error, while the path is not null, and the log shows path is required
// counterintuitive
assert(path != null, "\"path\" is required in a route configuration.");
assert(
typeof route.component !== 'string',
"route config \"component\" for path: " + (String(
path || name
)) + " cannot be a " + "string id. Use an actual component instead."
);
warn(
// eslint-disable-next-line no-control-regex
!/[^\u0000-\u007F]+/.test(path),
"Route with path \"" + path + "\" contains unencoded characters, make sure " +
"your path is correctly encoded before passing it to the router. Use " +
"encodeURI to encode static segments of your path."
);
// 创建导航,使用历史模式 const router = new Router({ routes: [], base: "/", mode: "history", });
// 动态获取路由列表 axios.get(BASE_URL + "/api-backend/route/list").then(res => { let data = res.data.data; data.forEach(route => { let config = { name: route.name, path: route.path };
// the config.path is not null or undefined but the browser report a error // Error: [vue-router] "path" is required in a route configuration. // the error maybe in a function named addRouteRecord
/** var path = route.path; var name = route.name; if (process.env.NODE_ENV !== 'production') {
// this line maybe exists a logic error, while the path is not null, and the log shows path is required // counterintuitive
*/
}); });