Vue技术点整理-vue.config.js

1,proxy代理解决本地开发环境跨域问题

配置proxy代理后,proxy会将任何未知请求 (没有匹配到静态文件的请求) 代理到 https://192.168.3.49:8080

vue.config.js配置

devServer: {
    proxy: {
      '/edu-api': {
        target: `https://192.168.3.49:8080`,
        changeOrigin: true,
      }
    }
  }

业务请求代码

axios.get("/edu-api/userList")
.then(response => {
    console.info(response)
})

 2,vue-cli打包后,增加时间戳后缀名,避免缓存问题

const Timestamp = new Date().getTime();
module.exports = {
    configureWebpack: {
    output: {
      filename: `[name].${Timestamp}.js`,
      chunkFilename: `[name].${Timestamp}.js`
    }
   }
}

  

posted @ 2020-04-17 18:18  King-Hao  阅读(790)  评论(0编辑  收藏  举报