rendering-with-data.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <template>
  2. <el-space direction="vertical" alignment="flex-start">
  3. <el-button @click="setLoading">Click me to reload</el-button>
  4. <el-skeleton style="width: 240px" :loading="loading" animated :count="3">
  5. <template #template>
  6. <el-skeleton-item variant="image" style="width: 400px; height: 267px" />
  7. <div style="padding: 14px">
  8. <el-skeleton-item variant="h3" style="width: 50%" />
  9. <div style="display: flex; align-items: center; justify-items: space-between; margin-top: 16px; height: 16px">
  10. <el-skeleton-item variant="text" style="margin-right: 16px" />
  11. <el-skeleton-item variant="text" style="width: 30%" />
  12. </div>
  13. </div>
  14. </template>
  15. <template #default>
  16. <el-card v-for="item in lists" :key="item.name" :body-style="{ padding: '0px', marginBottom: '1px' }">
  17. <img :src="item.imgUrl" class="image multi-content" />
  18. <div style="padding: 14px">
  19. <span>{{ item.name }}</span>
  20. <div class="bottom card-header">
  21. <div class="time">{{ currentDate }}</div>
  22. <el-button text class="button">Operation button</el-button>
  23. </div>
  24. </div>
  25. </el-card>
  26. </template>
  27. </el-skeleton>
  28. </el-space>
  29. </template>
  30. <script lang="ts" setup>
  31. import { onMounted, ref } from 'vue'
  32. interface ListItem {
  33. imgUrl: string
  34. name: string
  35. }
  36. const loading = ref(true)
  37. const lists = ref<ListItem[]>([])
  38. const currentDate = new Date().toDateString()
  39. const setLoading = () => {
  40. loading.value = true
  41. setTimeout(() => {
  42. loading.value = false
  43. }, 2000)
  44. }
  45. onMounted(() => {
  46. loading.value = false
  47. lists.value = [
  48. {
  49. imgUrl: 'https://fuss10.elemecdn.com/a/3f/3302e58f9a181d2509f3dc0fa68b0jpeg.jpeg',
  50. name: 'Deer',
  51. },
  52. {
  53. imgUrl: 'https://fuss10.elemecdn.com/1/34/19aa98b1fcb2781c4fba33d850549jpeg.jpeg',
  54. name: 'Horse',
  55. },
  56. {
  57. imgUrl: 'https://fuss10.elemecdn.com/0/6f/e35ff375812e6b0020b6b4e8f9583jpeg.jpeg',
  58. name: 'Mountain Lion',
  59. },
  60. ]
  61. })
  62. </script>