tui-no-data.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <view class="tui-nodata-box" :class="[fixed?'tui-nodata-fixed':'']">
  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. <view class="tui-tips-btn" hover-class="tui-btn__hover" :hover-stay-time="150" :style="{width:btnWidth+'rpx',height:btnHeight+'rpx',background:backgroundColor,borderRadius:radius,fontSize:size+'rpx'}" v-if="btnText" @tap="handleClick">{{btnText}}</view>
  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. //图片地址,没有则不显示
  20. imgUrl: {
  21. type: String,
  22. default: ""
  23. },
  24. //图片宽度
  25. imgWidth: {
  26. type: Number,
  27. default: 200
  28. },
  29. //图片高度
  30. imgHeight:{
  31. type: Number,
  32. default: 200
  33. },
  34. //按钮宽度
  35. btnWidth:{
  36. type: Number,
  37. default: 200
  38. },
  39. btnHeight:{
  40. type: Number,
  41. default: 60
  42. },
  43. //按钮文字,没有则不显示
  44. btnText:{
  45. type:String,
  46. default: ""
  47. },
  48. //按钮背景色
  49. backgroundColor:{
  50. type:String,
  51. default: "#EB0909"
  52. },
  53. size:{
  54. type:Number,
  55. default:28
  56. },
  57. radius:{
  58. type:String,
  59. default:'8rpx'
  60. }
  61. },
  62. methods: {
  63. handleClick(e) {
  64. this.$emit('click', {});
  65. }
  66. }
  67. }
  68. </script>
  69. <style scoped>
  70. .tui-nodata-box {
  71. display: flex;
  72. flex-direction: column;
  73. justify-content: center;
  74. align-items: center;
  75. }
  76. .tui-nodata-fixed {
  77. width: 90%;
  78. position: fixed;
  79. left: 50%;
  80. top: 50%;
  81. -webkit-transform: translate(-50%, -50%);
  82. transform: translate(-50%, -50%);
  83. }
  84. .tui-tips-icon {
  85. display: block;
  86. flex-shrink: 0;
  87. width: 280rpx;
  88. height: 280rpx;
  89. margin-bottom: 40rpx;
  90. }
  91. .tui-tips-content {
  92. text-align: center;
  93. color: #666666;
  94. font-size: 28rpx;
  95. padding: 0 50rpx 28rpx 50rpx;
  96. box-sizing: border-box;
  97. word-break: break-all;
  98. word-wrap: break-word;
  99. }
  100. .tui-tips-btn {
  101. color: #fff;
  102. margin: 0;
  103. display: flex;
  104. align-items: center;
  105. justify-content: center;
  106. }
  107. .tui-btn__hover{
  108. opacity: 0.5;
  109. }
  110. </style>