image.wxml 1.8 KB

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