noData.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template>
  2. <view class="no-data-view" :style="{ 'margin-top': conf.top + 'vh' }">
  3. <image v-if="conf.imgUrl" :style="{ width: conf.imgWidth, height: config.imgHeight }" :src="conf.imgUrl ? conf.imgUrl : $handleImageUrl('/nodata.png')"></image>
  4. <image v-if="!conf.imgUrl" class="no-data" :src="$handleImageUrl('/nodata.png')"></image>
  5. <view :style="{
  6. color: conf.color,
  7. 'font-size': conf.fSize,
  8. 'padding-top': conf.txtTop + 'rpx',
  9. }">{{ conf.content }}</view>
  10. </view>
  11. </template>
  12. <script setup name="noData">
  13. import { ref, watch } from "vue";
  14. const props = defineProps({
  15. config: {
  16. type: Object,
  17. default: function () {
  18. return {};
  19. },
  20. },
  21. });
  22. const conf = ref({
  23. type: "1",
  24. top: 22,
  25. imgWidth: 0,
  26. imgHeight: 0,
  27. imgUrl: "",
  28. content: "暂无数据~",
  29. fSize: 30,
  30. color: "#B3B3B3",
  31. txtTop: 20,
  32. });
  33. const init = () => {
  34. conf.value = Object.assign(conf.value, props.config);
  35. };
  36. watch(
  37. () => props.config,
  38. (newVal) => {
  39. conf.value = Object.assign(conf.value, newVal);
  40. }
  41. );
  42. init();
  43. </script>
  44. <style scoped>
  45. .no-data-view {
  46. text-align: center !important;
  47. }
  48. .no-data {
  49. width: 475rpx;
  50. height: 335rpx;
  51. }
  52. </style>