解决vue带路径部署到 nginx (部署到非根目录下)如http://localhost/doge/#/

  • 1.修改路由route/index
const router = new Router({
  base: '/doge/',   //修改这里
  mode: 'history',   //模式无所谓
  routes: [
    {
  • 2.修改config/index.js
  build: {
    // Template for index.html
    index: path.resolve(__dirname, '../dist/index.html'),

    // Paths
    assetsRoot: path.resolve(__dirname, '../dist'),
    assetsSubDirectory: 'static',
    assetsPublicPath: '/doge/',    /// 修改这里
  • 3.nginx 配置


    配置
  • 4.nginx vue打包文件放置
文件放置

可以支持多个