Vue ajax 请求后 更新 json数据

前端之家收集整理的这篇文章主要介绍了Vue ajax 请求后 更新 json数据前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

js

  1. $.ajax({
  2. type : "GET",url : "foucsLists.json",dataType : "json",success : function (data){
  3. var foucsLists = data["classify"];
  4. //vue
  5. var drawFocusLists = new Vue({
  6. el : "#focus-list",data : {
  7. todos : foucsLists
  8. }
  9. });
  10. //zui popover
  11. $('[data-toggle="popover"]').popover({
  12. trigger : 'hover',placement : 'top'
  13. });
  14. }
  15. });

json

  1. {
  2. "name" : "foucs","classify":[
  3. {
  4. "title" : "设计","content":[
  5. {"siteName" : "UI-Cloud","itemTitle" : "UI-Cloud","itemContent" : "UI搜索引擎,设计师必备,提供用户界面PSD下载","link" : "http://ui-cloud.com/"},{"siteName" : "优设网","itemTitle" : "高大上","itemContent" : "高大上的内容","link" : "http://www.uisdc.com/"},"link" : "http://www.uisdc.com/"}
  6. ]
  7. },{
  8. "title" : "前端","content":[
  9. {"siteName" : "前端1","link" : "www.baidu.com"},{"siteName" : "前端2",{"siteName" : "前端3",{"siteName" : "前端4","link" : "www.baidu.com"}
  10. ]
  11. }
  12. ]
  13. }

HTML

  1. <div class="page-content">
  2. <div id="focus">
  3. <!--focus list s-->
  4. <ul id="focus-list" class="">
  5. <li v-for="todo in todos" class="">
  6. <div class=" panel panel-info">
  7. <div v-cloak class="panel-heading">
  8. {{ todo.title }}
  9. </div>
  10. <div class="panel-body">
  11. <div class="item" v-for="list in todo.content">
  12. <a v-cloak :title="list.itemTitle" :href="list.link" data-toggle="popover" data-tip-class="popover-warning" :data-content="list.itemContent">{{ list.siteName }}</a>
  13. </div>
  14. </div>
  15. </div>
  16. </li>
  17. </ul>
  18. <!--focus list e-->
  19. </div>
  20. </div>

猜你在找的Ajax相关文章