found a new vue-cli scaffolding with multi-page configuration items. Try to configure the document . You can visit each page, but when you refresh, the route to the corresponding page cannot be found. The code is as follows
.// vue.config.js
module.exports = {
baseUrl: process.env.NODE_ENV === "production"
? "/ems/"
: "/ems/",
pages: {
admin: {
entry: "src/views/admin/main.js",
template: "public/admin.html",
filename: "admin/index.html",
},
school: {
entry: "src/views/school/main.js",
template: "public/school.html",
filename: "school/index.html",
}
}
}
// admin.routes.js
import Vue from "vue"
import Router from "vue-router"
import Home from "@/views/admin/Home.vue"
import Layout from "@/components/layout-admin"
Vue.use(Router)
const routes = [
{
path: "/",
redirect: {name: "admin"},
},
{
path: "/admin",
name: "admin",
component: Layout,
redirect: {name: "home"},
children: [
{
path: "home",
name: "home",
component: Home
},
{
path: "about",
name: "about",
component: () => import("./../views/admin/About.vue")
}
]
}
]
export default new Router({
mode: "history",
base: process.env.BASE_URL,
routes
})
it is possible to access / ems/admin
by accessing / ems/admin/home
route, but it is impossible to access / ems/admin/home
directly.