Blogger Information
Blog 20
fans 1
comment 1
visits 30599
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
vue-resource ajax请求
大瓶可乐
Original
689 people have browsed it

``

  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>``
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post