vue-resource ajax请求
16lz
2022-03-04
``
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>vue-resource ajax请求</title>
<script src="https://cdn.staticfile.org/vue/2.4.2/vue.min.js"></script>
<script src="https://cdn.staticfile.org/vue-resource/1.5.1/vue-resource.min.js"></script>
</head>
<body>
<div id="box">
<ol>
<li v-for="site in sites">
{{ site.name }}
</li>
</ol>
</div>
<script type = "text/javascript">
window.onload = function(){
var vm = new Vue({
el:'#box',
data:{
sites: []
},
created: function () {
//发送get请求
this.$http.jsonp('https://www.test.com/index.php/api/v1/category').then(function(res){
this.sites = res.body.data.son;
},function(){
console.log('请求失败处理');
});
}
});
}
</script>
</body>
</html>``
更多相关文章
- Android的第三个应用---短信发送器
- Android(安卓)的网络编程
- Android(安卓)发送短信 和 打电话 具体事项
- Android(安卓)Retrofit 源码系列(一)~ 原理剖析
- android之Intent几个基础用法示例
- android开心网语音发送模块的录音功能
- Android聊天软件开发(基于网易云IM即时通讯)——发送文本消息(四)
- Android:短信发送器
- 封装Android的AsyncHttpClient请求工具