``

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>vue-resource ajax请求</title>
  6. <script src="https://cdn.staticfile.org/vue/2.4.2/vue.min.js"></script>
  7. <script src="https://cdn.staticfile.org/vue-resource/1.5.1/vue-resource.min.js"></script>
  8. </head>
  9. <body>
  10. <div id="box">
  11. <ol>
  12. <li v-for="site in sites">
  13. {{ site.name }}
  14. </li>
  15. </ol>
  16. </div>
  17. <script type = "text/javascript">
  18. window.onload = function(){
  19. var vm = new Vue({
  20. el:'#box',
  21. data:{
  22. sites: []
  23. },
  24. created: function () {
  25. //发送get请求
  26. this.$http.jsonp('https://www.test.com/index.php/api/v1/category').then(function(res){
  27. this.sites = res.body.data.son;
  28. },function(){
  29. console.log('请求失败处理');
  30. });
  31. }
  32. });
  33. }
  34. </script>
  35. </body>
  36. </html>``

更多相关文章

  1. Android的第三个应用---短信发送器
  2. Android(安卓)的网络编程
  3. Android(安卓)发送短信 和 打电话 具体事项
  4. Android(安卓)Retrofit 源码系列(一)~ 原理剖析
  5. android之Intent几个基础用法示例
  6. android开心网语音发送模块的录音功能
  7. Android聊天软件开发(基于网易云IM即时通讯)——发送文本消息(四)
  8. Android:短信发送器
  9. 封装Android的AsyncHttpClient请求工具

随机推荐

  1. c语言*p++是什么意思?
  2. .net和c#有什么区别
  3. C ++中continue和break语句的简单比较
  4. c语言计算两个数的最小公倍数
  5. 如何判断文件是否存在于Perl中
  6. 什么是变量的作用域
  7. 如何用Perl表示当前时间
  8. c语言如何实现选择排序算法(代码示例)
  9. 伪代码是什么?如何写一个伪代码?
  10. c语言简单数据类型有哪些