ContentLoader.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <template>
  2. <div>
  3. <div :style="{ height: 300, width: '100%' }"></div>
  4. <content-loader
  5. :height="fixedAmount * count"
  6. :width="1060"
  7. :speed="2"
  8. primaryColor="#d9d9d9"
  9. secondaryColor="#ecebeb"
  10. >
  11. <template v-for="index in count">
  12. <rect x="13" :y="fixedAmount * index + offset" rx="6" ry="6" :width="200 * random()" height="12" />
  13. <rect x="533" :y="fixedAmount * index + offset" rx="6" ry="6" :width="63 * random()" height="12" />
  14. <rect x="653" :y="fixedAmount * index + offset" rx="6" ry="6" :width="78 * random()" height="12" />
  15. <rect x="755" :y="fixedAmount * index + offset" rx="6" ry="6" :width="117 * random()" height="12" />
  16. <rect x="938" :y="fixedAmount * index + offset" rx="6" ry="6" :width="83 * random()" height="12" />
  17. <rect x="0" :y="fixedAmount * index" rx="6" ry="6" width="1060" height=".3" />
  18. </template>
  19. </content-loader>
  20. </div>
  21. </template>
  22. <script>
  23. import { ContentLoader } from 'vue-content-loader';
  24. export default {
  25. props: ['store'],
  26. data: () => ({
  27. fixedAmount: 31,
  28. offset: 10,
  29. steps: [0.7, 0.8, 0.9, 1]
  30. }),
  31. computed: {
  32. count() {
  33. return this.store.perPage;
  34. }
  35. },
  36. methods: {
  37. random() {
  38. return this.steps[Math.floor(Math.random() * this.steps.length)];
  39. }
  40. },
  41. components: {
  42. ContentLoader
  43. }
  44. }
  45. </script>