方式一:(mode:history)
webpack.base.conf.js
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: '/', // 注意是绝对路径
nginx 配置文件
http{
server {
location / {
try_files $uri $uri/ /index.html; // 加上这行配置
}
}
}
方式二:(mode:hash)
webpack.base.conf.js
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: './', // 注意是相对路径