image.wxml 1.7 KB

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