zoukankan      html  css  js  c++  java
  • vue跨域配置

    根目录新建  vue.config.js文件:

    添加如下代码:

     1 module.exports = {
     2   outputDir: 'dist', //build输出目录
     3   assetsDir: 'assets', //静态资源目录(js, css, img)
     4   lintOnSave: false, //是否开启eslint
     5   devServer: {
     6     open: true, //是否自动弹出浏览器页面
     7     host: "localhost",
     8     port: '8081',
     9     https: false,
    10     hotOnly: false,
    11     proxy: {
    12       '/api': {14         target: 'http://erp.f-ev.com/PBaoXFIsvT.php/facrm/analysis', //自己的服务器的地址
    15         changeOrigin: true,
    16         pathRewrite: {
    17           '^/api': ''
    18 
    19         }
    20       }
    21     }
    22   }
    23 }

    然后请求写法 URL前缀加上api即可:

    this.$axios({
              method: 'post',
              url: '/api/Kpi/selectpage_yunying',
            }).then((res) => {
              if (res.data.code == "200") {
                
              }
            });

    到此结束!

  • 相关阅读:
    洛谷
    洛谷
    洛谷
    洛谷
    洛谷
    模板
    模板
    模板
    洛谷
    模板
  • 原文地址:https://www.cnblogs.com/Ifyou/p/15479196.html
Copyright © 2011-2022 走看看