index.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <template>
  2. <uni-shadow-root class="vant-empty-index"><view class=" custom-class van-empty">
  3. <view class="van-empty__image">
  4. <image v-if="imageUrl" class="van-empty__image__img" mode="widthFix" src="/static/img/notData.png"></image>
  5. </view>
  6. <p class="van-empty__description" v-if="description">
  7. {{ description }}
  8. </p>
  9. <view class="van-empty__bottom">
  10. <slot></slot>
  11. </view>
  12. </view></uni-shadow-root>
  13. </template>
  14. <wxs src="../wxs/utils.wxs" module="utils"></wxs>
  15. <script>
  16. global['__wxVueOptions'] = {components:{}}
  17. global['__wxRoute'] = 'vant/empty/index'
  18. import { VantComponent } from '../common/component';
  19. const PRESETS = ['error', 'search', 'default', 'network'];
  20. VantComponent({
  21. props: {
  22. description: String,
  23. image: {
  24. type: String,
  25. value: 'default',
  26. },
  27. },
  28. created() {
  29. if (PRESETS.indexOf(this.data.image) !== -1) {
  30. this.setData({
  31. imageUrl: `https://img.yzcdn.cn/vant/empty-image-${this.data.image}.png`,
  32. });
  33. } else {
  34. this.setData({ imageUrl: this.data.image });
  35. }
  36. },
  37. });
  38. export default global['__wxComponents']['vant/empty/index']
  39. </script>
  40. <style platform="mp-weixin">
  41. @import '../common/index.css';.van-empty{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;-webkit-align-items:center;align-items:center;-webkit-justify-content:center;justify-content:center;box-sizing:border-box;padding:0}.van-empty__image{width:160px;}.van-empty__image__img{width:100%;height:100%}.van-empty__description{margin-top:16px;padding:0 60px;color:#969799;font-size:14px;line-height:20px}.van-empty__bottom{margin-top:24px}
  42. </style>