vue脚手架项目如何运行在服务器(How does the Vue scaffolding project run on the server)

用vue-cli创建的vue项目,直接执行npm run build命令或者使用图形化页面压缩后,得到一个dist文件夹,但此时文件中的index.html打开后一片空白,为路径问题,

so在src的同级目录下创建一个vue.config.js文件(已有的话则修改相应内容),向其中写入配置信息并保存:

module.exports = {
  publicPath: './',
  outputDir: 'dist',
  assetsDir: 'static'
}

在router的index.js的const router = new VueRouter({…})代码块中,如果存在

mode: 'history'的模式设定,则需要将此设定注释掉(或删掉)。

之后再执行npm run build命令

————————

For the Vue project created with Vue cli, directly execute the NPM run build command or use the graphical page compression to get a dist folder, but the index in the file is Html is blank after opening, which is the path problem,

So creates a Vue in the same level directory of SRC config. JS file (modify the corresponding content if it already exists), write configuration information to it and save it:

module.exports = {
  publicPath: './',
  outputDir: 'dist',
  assetsDir: 'static'
}

In router’s index JS const router = new vueroter ({…}) Code block, if present

mode: 'history'的模式设定,则需要将此设定注释掉(或删掉)。

Then execute the NPM run build command