<script type="text/javascript">
var vm = new Vue({
el:'#app',
data:{
msg:'hello world'
},
methods:{
getInfo(){
this.$http.jsonp('http://api.vue-tp5.com/v1/index/index').then(function(result){
console.log(result)
}).catch(function(error){
console.log(error);
});
}
}
});
</script>
在then后加上catch即可
本文介绍如何在Vue.js项目中使用jsonp实现跨域数据获取,通过实例演示了Vue.js结合$http进行jsonp请求的方法,并展示了如何处理成功和失败的情况。
4569

被折叠的 条评论
为什么被折叠?



