tui-no-data.vue 2.2 KB

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