Modified the base property of vue-router to the root directory, why does the routing view still not appear after packaging?

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

clipboard.png

index.html

clipboard.png

Mar.29,2021

this is the operating system file access address. You need to open a service and access your project

.
Menu