首先在index.html中添加meta不缓存

<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.config.js里打包时js,css配置时间戳,区别版本

// 打包时添加时间戳,区别版本
const Version = new Date().getTime();
const isPro = process.env.NODE_ENV === 'production'
configureWebpack: {
    output: {
      filename: `js/[name].${Version}.js`,
      chunkFilename: `js/[name].${Version}.js`,
    },
  },
  //其他代码
chainWebpack: (config) => {
    // 删除 prefetch 选项:  预加载
    config.plugins.delete("prefetch");
    if (isPro) {
      config.plugin('extract-css').tap((args) => [
        {
          filename: `css/[name].${Version}.css`,
          chunkFilename: `css/[name].${Version}.css`,
        },
      ])
    }
    //其他代码
  },
Logo

前往低代码交流专区

更多推荐