index.wxml 992B

1234567891011121314151617181920212223242526272829303132333435
  1. <wxs src="../wxs/utils.wxs" module="utils" />
  2. <wxs src="./index.wxs" module="computed" />
  3. <view
  4. style="{{ computed.rootStyle({ width, height, radius }) }}"
  5. class="custom-class {{ utils.bem('image', { round })}}"
  6. bind:tap="onClick"
  7. >
  8. <image
  9. wx:if="{{ !error }}"
  10. src="{{ src }}"
  11. mode="{{ computed.mode(fit) }}"
  12. lazy-load="{{ lazyLoad }}"
  13. class="image-class van-image__img"
  14. show-menu-by-longpress="{{ showMenuByLongpress }}"
  15. bind:load="onLoad"
  16. bind:error="onError"
  17. />
  18. <view
  19. wx:if="{{ loading && showLoading }}"
  20. class="loading-class van-image__loading"
  21. >
  22. <slot wx:if="{{ useLoadingSlot }}" name="loading" />
  23. <van-icon wx:else name="photo" custom-class="van-image__loading-icon" />
  24. </view>
  25. <view
  26. wx:if="{{ error && showError }}"
  27. class="error-class van-image__error"
  28. >
  29. <slot wx:if="{{ useErrorSlot }}" name="error" />
  30. <van-icon wx:else name="photo-fail" custom-class="van-image__error-icon" />
  31. </view>
  32. </view>