image.wxml 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <wxs src="../common/utils.wxs" module="_" />
  2. <view style="{{_._style([style, customStyle])}}" class="class {{prefix}}-class {{classPrefix}}">
  3. <!-- 加载中占位 -->
  4. <view
  5. wx:if="{{isLoading}}"
  6. style="{{_._style([innerStyle])}}"
  7. class="{{classPrefix}}__mask {{classPrefix}}--loading {{classPrefix}}--shape-{{shape}}"
  8. aria-hidden="{{ariaHidden}}"
  9. >
  10. <t-loading
  11. wx:if="{{loading === 'default'}}"
  12. theme="dots"
  13. size="44rpx"
  14. loading
  15. inherit-color
  16. t-class="t-class-load"
  17. t-class-text="{{classPrefix}}--loading-text"
  18. ></t-loading>
  19. <view wx:elif="{{loading !== '' && loading !== 'slot'}}" class="{{classPrefix}}__common {{prefix}}-class-load">
  20. {{loading}}
  21. </view>
  22. <slot wx:else name="loading" />
  23. </view>
  24. <!-- 加载失败占位 -->
  25. <view
  26. wx:elif="{{isFailed}}"
  27. style="{{_._style([innerStyle])}}"
  28. class="{{classPrefix}}__mask {{classPrefix}}--failed {{classPrefix}}--shape-{{shape}} {{prefix}}-class-error"
  29. aria-hidden="{{ariaHidden}}"
  30. >
  31. <view wx:if="{{error === 'default'}}" style="font-size: 44rpx" class="{{prefix}}-class-load">
  32. <t-icon name="close" aria-role="img" aria-label="加载失败" />
  33. </view>
  34. <view wx:elif="{{error && error !== 'slot'}}" class="{{classPrefix}}__common {{prefix}}-class-load">
  35. {{error}}
  36. </view>
  37. <slot wx:else name="error" />
  38. </view>
  39. <!-- 图片 -->
  40. <image
  41. id="{{tId||'image'}}"
  42. wx:if="{{ !isFailed }}"
  43. style="{{_._style([innerStyle])}}"
  44. class="{{classPrefix}}__img {{classPrefix}}--shape-{{shape}} {{isLoading ? classPrefix + '--lazy' : ''}} {{prefix}}-class-image"
  45. src="{{src}}"
  46. mode="{{mode}}"
  47. webp="{{webp}}"
  48. lazy-load="{{lazy}}"
  49. bind:load="onLoaded"
  50. bind:error="onLoadError"
  51. show-menu-by-longpress="{{showMenuByLongpress}}"
  52. aria-hidden="{{ariaHidden || isLoading || isFailed}}"
  53. aria-label="{{ariaLabel}}"
  54. />
  55. </view>