vue项目部署(npm run build二级域名)

vue脚手架 默认启动打开的路由后 自动加 # 号html

项目涉及需求:访问二级域名 才是该页面 vue

eg:xxx.com/xx 才是本项目的内容npm

修改以下:bash

router:index.js 去掉 # 号服务器

const router = new Router({
  mode: 'history',
  base: '/md',
  routes: [
    {
      path: '*',
      component: notFound
    },
    {
      path: '/',
      name: 'xx',
      component: xx
    }
  ]
})复制代码

打包npm run build 生成 index.html 须要更换一下位置:ui

config/index.js  (须要改动3个地方,以下)spa

module.exports = {
  build: {
    env: env,
    index: path.resolve(__dirname, '../dist/md/index.html'),
    assetsRoot: path.resolve(__dirname, '../dist/md'),
    assetsPublicPath: '/md/',
复制代码

而后须要服务器改一下地址指向这个项目就能够了code

相关文章
相关标签/搜索