tui-no-data.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <view class="tui-nodata-box" :class="[fixed?'tui-nodata-fixed':'']" :style="{padding:padding}">
  3. <image v-if="imgUrl" :src="imgUrl" class="tui-tips-icon" :style="{width:imgWidth+'rpx',height:imgHeight+'rpx'}"></image>
  4. <view class="tui-tips-content">
  5. <slot></slot>
  6. </view>
  7. <button class="tui-tips-btn" hover-class="tui-tips-btn-hover" :style="{width:btnWidth+'rpx'}" v-if="btnText" @tap="handleClick">{{btnText}}</button>
  8. </view>
  9. </template>
  10. <script>
  11. export default {
  12. name: "tuiNoData",
  13. props: {
  14. //是否垂直居中
  15. fixed: {
  16. type: Boolean,
  17. default: true
  18. },
  19. padding: {
  20. type: String,
  21. default: ""
  22. },
  23. //图片地址,没有则不显示
  24. imgUrl: {
  25. type: String,
  26. default: ""
  27. },
  28. //图片宽度
  29. imgWidth: {
  30. type: [Number, String],
  31. default: 200
  32. },
  33. //图片高度
  34. imgHeight:{
  35. type: [Number, String],
  36. default: 200
  37. },
  38. //按钮宽度
  39. btnWidth:{
  40. type: [Number, String],
  41. default: 200
  42. },
  43. //按钮文字,没有则不显示
  44. btnText:{
  45. type:String,
  46. default: ""
  47. }
  48. },
  49. methods: {
  50. handleClick(e) {
  51. this.$emit('click', {});
  52. }
  53. }
  54. }
  55. </script>
  56. <style scoped>
  57. .tui-nodata-box {
  58. display: flex;
  59. flex-direction: column;
  60. justify-content: center;
  61. align-items: center;
  62. }
  63. .tui-nodata-fixed {
  64. width: 90%;
  65. position: fixed;
  66. left: 50%;
  67. top: 50%;
  68. -webkit-transform: translate(-50%, -50%);
  69. transform: translate(-50%, -50%);
  70. }
  71. .tui-tips-icon {
  72. display: block;
  73. flex-shrink: 0;
  74. width: 280rpx;
  75. height: 280rpx;
  76. margin-bottom: 0rpx;
  77. }
  78. .tui-tips-content {
  79. text-align: center;
  80. color: #999999;
  81. font-size: 28rpx;
  82. padding: 0 50rpx;
  83. box-sizing: border-box;
  84. word-break: break-all;
  85. word-wrap: break-word;
  86. }
  87. .tui-tips-btn {
  88. height: 60rpx;
  89. line-height: 60rpx;
  90. font-size: 28rpx;
  91. background-color: #EB0909;
  92. color: #fff;
  93. border-radius: 6rpx;
  94. margin: 0;
  95. }
  96. .tui-tips-btn-hover {
  97. background-color: #c80808;
  98. color: #e5e5e5;
  99. }
  100. </style>