placeholder.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <!--
  2. * @Author: colpu ycg520520@qq.com
  3. * @Date: 2024-07-30 10:45:32
  4. * @LastEditors: colpu ycg520520@qq.com
  5. * @LastEditTime: 2024-07-30 10:45:57
  6. * @FilePath: components/placeholder.vue
  7. * @Description:
  8. -->
  9. <template>
  10. <view class="colpu__placeholder-wrap" :style="styles">
  11. <view class="colpu__placeholder-img">
  12. <image :style="imageStyle" lazy-load="true" :src="src"></image>
  13. </view>
  14. <rich-text
  15. class="colpu__placeholder-desc"
  16. v-if="desc.length"
  17. :nodes="desc"
  18. ></rich-text>
  19. <view class="colpu__placeholder-slot" :style="`margin-bottom:${offset}`">
  20. <slot></slot>
  21. </view>
  22. </view>
  23. </template>
  24. <script setup>
  25. defineProps({
  26. src: {
  27. type: String,
  28. default: "/static/svgs/noinfo.svg",
  29. },
  30. desc: {
  31. type: String,
  32. default: "空空如也!",
  33. },
  34. styles: {
  35. type: [Object, String],
  36. default: "",
  37. },
  38. imageStyle: {
  39. type: [Object, String],
  40. default: () => ({
  41. width: "96px",
  42. height: "96px",
  43. }),
  44. },
  45. offset: { type: String, default: "0" },
  46. });
  47. </script>
  48. <script>
  49. export default {
  50. options: {
  51. virtualHost: true,
  52. },
  53. };
  54. </script>
  55. <style lang="scss" scoped>
  56. $lead: '.colpu__';
  57. #{$lead}placeholder {
  58. &-wrap {
  59. text-align: center;
  60. display: flex;
  61. flex-direction: column;
  62. justify-content: center;
  63. align-items: center;
  64. flex: 1;
  65. height: 100%;
  66. }
  67. &-img {
  68. }
  69. &-desc {
  70. display: inline-block;
  71. text-align: center;
  72. font-size: 24rpx;
  73. color: #ccc;
  74. }
  75. &-slot {
  76. display: inline-block;
  77. }
  78. }
  79. </style>