configure base as follows
router/index.js
function getAbsolutePath () {
let path = location.pathname
console.log(path)
// /C:/Users/csq94/Desktop/python/vue/secSinglePage/dist/index.html
console.log(path.substring(0, path.lastIndexOf("/") - 5))
/C:/Users/csq94/Desktop/python/vue/secSinglePage
return path.substring(0, path.lastIndexOf("/") - 5)
}
const router = new Router({
routes,
mode: "history",
base: getAbsolutePath()
})
configure the packaging file path:
vue.config.js
module.exports = {
baseUrl: "./",
outputDir: "../dist"
}
the file directory is as follows
index.html