vue-router History of local development environment and configuration nginx

vue-router mode = history local development environment configuration

Solution 1. Modify the devServer CI webpack (devServe present in, rvue-cli2 in webapck.config.js, vue-cli3 in vue.config.js), add historyApiFallback: true 

Some documents are also on webpack: https://webpack.js.org/configuration/dev-server/#devserverhistoryapifallback

module.exports = {
  //...
  devServer: {
   historyApiFallback: true
  }
};

Solution 2: Modify the value of the dev package.json inside srcipts

webpack-dev-server --history-api-fallback

 

 


vue-router mode = history nginx arrangement

Outset how the test will not work, and finally found ourselves digging, mainly under the summary is not found publicPath I became ./ set, resulting in an unsuccessful attempt has been here publicPath Why set to /, vue-cli write Ming address

Solving steps 1

2.nginx profile

The solution is simple, one vue.config.js (vue-cli3) publicPath provided, one is to increase nginx try_files $ uri $ uri / /index.html;

Under normal circumstances, you can set up successful, if unsuccessful, to look for their own reasons for code writing this document also hope to help others

Guess you like

Origin www.cnblogs.com/zph666/p/11468883.html