在入口文件index.html添加
<meta http-equiv="pragram" content="no-cache">
<meta http-equiv="cache-control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="expires" content="0">
因瀏覽器緩存原因導致vue 打包后的文件不能即使更新最新代碼。緩存里的內容沒有清除。(基本沒作用)
解決辦法就是在打包的文件名中添加一個版本號以便瀏覽器能區分。
build--webpack .prod.conf.js
const Version = new Date().getTime(); //定義一個時間作為版本號。
output: {
path: config.build.assetsRoot,
filename: utils.assetsPath('js/[name].[chunkhash]'+ Version+'.js'),
chunkFilename: utils.assetsPath('js/[id].[chunkhash]'+Version +'.js')
}