no-data.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <view class="slot">
  3. <!-- <view class="img"><image :src="'../static/nodata/' + type + '.png'" mode="widthFix"></image></view>
  4. <view class="tip">{{ returnTip(tip) }}</view> -->
  5. <u-empty :text="returnTip(tip)" :mode="type"></u-empty>
  6. </view>
  7. </template>
  8. <script>
  9. export default {
  10. name: 'no-data',
  11. props: {
  12. // 类型,缺省图片名称,路径:/static/nodata/...
  13. type: {
  14. type: String,
  15. default: 'list'
  16. },
  17. // 自定义文本
  18. tip: {
  19. type: String,
  20. default: ''
  21. }
  22. },
  23. data() {
  24. return {
  25. ops: [
  26. { type: 'list', tip: '暂无数据' },
  27. // { type: 'collection', tip: '暂无收藏' },
  28. // { type: 'fans', tip: '暂无粉丝' },
  29. // { type: 'network', tip: '暂无网络' },
  30. { type: 'order', tip: '暂无订单' },
  31. // { type: 'news', tip: '暂无消息' },
  32. // { type: 'result', tip: '暂无搜索结果' }
  33. ]
  34. };
  35. },
  36. methods: {
  37. returnTip(tip) {
  38. if (tip) {
  39. return tip;
  40. } else {
  41. return this.ops.filter(item => item.type == this.type)[0].tip;
  42. }
  43. }
  44. }
  45. };
  46. </script>
  47. <style lang="scss" scoped>
  48. .slot {
  49. width: 100%;
  50. // height: 100%;
  51. display: flex;
  52. align-items: center;
  53. justify-content: center;
  54. align-content: center;
  55. flex-wrap: wrap;
  56. margin-top: 100rpx;
  57. .img {
  58. width: 400rpx;
  59. height: auto;
  60. image {
  61. width: 100%;
  62. height: auto;
  63. }
  64. }
  65. .tip {
  66. margin-top: 48rpx;
  67. width: 100%;
  68. text-align: center;
  69. font-size: 30rpx;
  70. font-weight: 400;
  71. color: $app-theme-text-color;
  72. }
  73. }
  74. </style>