list-group.blade.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <div class="{{$id}}" id="{{$id}}" style="margin-bottom: 20px">
  2. <div class="box-loading sp sp-circle"></div>
  3. <ul class="list-group" v-if="load_status">
  4. <li v-for="(item, index) in items" class="list-group-item d-flex justify-content-between align-items-center">
  5. <a :href="item.link" target="_blank">@{{ item.title }}</a>
  6. <span class="badge badge-secondary badge-pill">@{{ item.datetime }}</span>
  7. </li>
  8. </ul>
  9. </div>
  10. <script>
  11. Dcat.ready(function () {
  12. new Vue({
  13. el: `#{{$id}}`,
  14. data: {
  15. load_status:false,
  16. items: []
  17. },
  18. created:function(){
  19. let that = this;
  20. $.ajax({
  21. url: '{!! $ajax_url !!}',
  22. type: '{{$ajax_method}}', // 设置请求方法为POST
  23. headers:{!! $ajax_headers !!},
  24. data:{!! $ajax_data !!},
  25. }).then(function(resp) {
  26. console.log(resp);
  27. if (resp.code == 200) {
  28. that.items = resp.data;
  29. that.load_status = true; // 设置load_status为true
  30. $('#{{{$id}}}').find('.box-loading').hide();
  31. console.log();
  32. }
  33. });
  34. },
  35. mounted: function() {
  36. // 在Vue实例渲染完成后执行的操作
  37. //document.querySelector(`#${{{$id}}}`).querySelector('.box-loading').style.display = 'none'; // 隐藏box-loading
  38. }
  39. });
  40. });
  41. </script>