badge.wxml 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <wxs src="./badge.wxs" module="this" />
  2. <wxs src="../common/utils.wxs" module="_" />
  3. <!--
  4. 1. labelID 用于描述当前元素的文本
  5. 2. descriptionID 用于描述badge消息的文本
  6. 3. role=option一般用于多个内容合并焦点连续朗读
  7. -->
  8. <view
  9. style="{{_._style([style, customStyle])}}"
  10. class="{{this.getBadgeOuterClass({shape})}} class {{prefix}}-class"
  11. aria-labelledby="{{labelID}}"
  12. aria-describedby="{{descriptionID}}"
  13. aria-role="{{ ariaRole || 'option'}}"
  14. >
  15. <view id="{{labelID}}" class="{{classPrefix}}__content {{prefix}}-class-content" aria-hidden="true">
  16. <slot wx:if="{{!content}}" class="{{classPrefix}}__content-slot" />
  17. <text wx:else class="{{classPrefix}}__content-text">{{content}}</text>
  18. </view>
  19. <view
  20. aria-hidden="true"
  21. aria-label="{{ ariaLabel || _.getBadgeAriaLabel({dot, count, maxCount}) }}"
  22. wx:if="{{this.isShowBadge({dot,count,showZero})}}"
  23. id="{{descriptionID}}"
  24. class="{{this.getBadgeInnerClass({dot, size, shape, count})}} {{prefix}}-has-count {{prefix}}-class-count"
  25. style="{{this.getBadgeStyles({color, offset})}}"
  26. aria-hidden="true"
  27. aria-label="{{ ariaLabel || _.getBadgeAriaLabel({dot, count, maxCount}) }}"
  28. >
  29. <view
  30. wx:if="{{shape == 'ribbon'}}"
  31. class="t-badge__ribbon--before"
  32. style="{{color ? 'border-color: ' + color : ''}}"
  33. />
  34. {{ this.getBadgeValue({dot, count, maxCount}) }}
  35. <view
  36. wx:if="{{shape == 'ribbon'}}"
  37. class="t-badge__ribbon--after"
  38. style="{{color ? 'border-color: ' + color : ''}}"
  39. />
  40. </view>
  41. <slot name="count" />
  42. </view>