vue 里面 如何用$http.post 实现跨域请求
2个回答
展开全部
1.在项目跟目录上安装:
[html] view plain copy
npm install vue-resource
2.引入resource插件
[html] view plain copy
import VueResource from 'vue-resource';
Vue.use(VueResource)
3.发送请求:
[html] view plain copy
this.$http.get("http://www.vrserver.applinzi.com/aixianfeng/apihome.php").then(function(res){
console.log(res)
})
ES6写法:
[html] view plain copy
<span style="font-family:'Microsoft YaHei';font-size:18px;">this.$http.get('url', [options]).then((res) => {
</span>
[html] view plain copy
<span style="font-family:'Microsoft YaHei';font-size:18px;">// 处理成功的结果</span>
[html] view plain copy
npm install vue-resource
2.引入resource插件
[html] view plain copy
import VueResource from 'vue-resource';
Vue.use(VueResource)
3.发送请求:
[html] view plain copy
this.$http.get("http://www.vrserver.applinzi.com/aixianfeng/apihome.php").then(function(res){
console.log(res)
})
ES6写法:
[html] view plain copy
<span style="font-family:'Microsoft YaHei';font-size:18px;">this.$http.get('url', [options]).then((res) => {
</span>
[html] view plain copy
<span style="font-family:'Microsoft YaHei';font-size:18px;">// 处理成功的结果</span>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询