1 <script> 2 $ajax({ 3 type: "get", 4 url: "接口地址" 5 datatype: "jsonp"//这里写成jsonp 6 success: function (response) { 7 console.log(response) 8 } 9 }) 10 </script>
dev: { // 如果后端提供的接口为: /test/where assetsSubDirectory: ‘static‘, assetsPublicPath: ‘/‘, proxyTable: { ‘/proxyApi‘: { target: ‘http://xxxx.com‘, // 后端提供给你的接口地址 changeOrigin: true, // true开启跨域 pathRewrite: { ‘^/proxyApi‘: ‘/proxyApi‘ // 代理api使用方法=> /proxyApi/test/where } } }
好,就先写到这里
原文:https://www.cnblogs.com/Coolcatmenthol/p/14494530.html