listquestions.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <template>
  2. <div style="height: 100%;">
  3. <van-pull-refresh class="inspect-object-question-wrapper" v-model="loading" @refresh="getData()">
  4. <!-- 使用 v-for 指令遍历 list 数组 -->
  5. <card01 v-for="item in list" :key="item.id" :title="item.pblmNm + ''" :icon="pblmPasiConvert(item.pblmPasi)"
  6. :description="renderData(item, item.pblmDesc)" :ellipsisDescription="true"
  7. @click="jumpPage(`/problem/${item.id}`)" />
  8. </van-pull-refresh>
  9. </div>
  10. </template>
  11. <script setup>
  12. import { renderData } from "@/utils/template";
  13. import { jumpPage } from "@/utils/page";
  14. import { getTacQuestionList } from "@/api/questions";
  15. import { onMounted, ref } from "vue";
  16. import card01 from '@/components/card01.vue';
  17. import { pblmPasiConvert } from "@/utils/convert";
  18. // 使用 ref 定义响应式变量 list 和 loading
  19. const list = ref([]);
  20. const loading = ref(false);
  21. // 定义 getData 函数,用于获取数据
  22. function getData() {
  23. // 设置 loading 为 true,表示正在加载数据
  24. loading.value = true;
  25. // 调用 getTacQuestionList 接口获取数据
  26. getTacQuestionList().then(res => {
  27. // 将接口返回的数据赋值给 list
  28. list.value = res.data.list;
  29. console.log(list.value);
  30. // 设置 loading 为 false,表示数据加载完成
  31. loading.value = false;
  32. })
  33. }
  34. // 在组件挂载后调用 getData 函数获取数据
  35. onMounted(() => {
  36. getData();
  37. })
  38. </script>
  39. <style lang="scss" scoped>
  40. .inspect-object-wrapper {
  41. width: 100%;
  42. height: 100%;
  43. overflow: auto;
  44. }
  45. </style>