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`
    }
   }
}

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM