riku
2026-01-16 1f9e43b7bbb848c7ee2aaa89ffece17002b2c915
miniprogram_npm/tdesign-miniprogram/badge/badge.wxml
@@ -1,44 +1 @@
<wxs src="./badge.wxs" module="this" />
<wxs src="../common/utils.wxs" module="_" />
<!--
  1. labelID 用于描述当前元素的文本
  2. descriptionID 用于描述badge消息的文本
  3. role=option一般用于多个内容合并焦点连续朗读
-->
<view
  style="{{_._style([style, customStyle])}}"
  class="{{this.getBadgeOuterClass({shape})}} class {{prefix}}-class"
  aria-labelledby="{{labelID}}"
  aria-describedby="{{descriptionID}}"
  aria-role="{{ ariaRole || 'option'}}"
>
  <view id="{{labelID}}" class="{{classPrefix}}__content {{prefix}}-class-content" aria-hidden="true">
    <slot wx:if="{{!content}}" class="{{classPrefix}}__content-slot" />
    <text wx:else class="{{classPrefix}}__content-text">{{content}}</text>
  </view>
  <view
    aria-hidden="true"
    aria-label="{{ ariaLabel || _.getBadgeAriaLabel({dot, count, maxCount}) }}"
    wx:if="{{this.isShowBadge({dot,count,showZero})}}"
    id="{{descriptionID}}"
    class="{{this.getBadgeInnerClass({dot, size, shape, count})}} {{prefix}}-has-count {{prefix}}-class-count"
    style="{{this.getBadgeStyles({color, offset})}}"
    aria-hidden="true"
    aria-label="{{ ariaLabel || _.getBadgeAriaLabel({dot, count, maxCount}) }}"
  >
    <view
      wx:if="{{shape == 'ribbon'}}"
      class="t-badge__ribbon--before"
      style="{{color ? 'border-color: ' + color : ''}}"
    />
    {{ this.getBadgeValue({dot, count, maxCount}) }}
    <view
      wx:if="{{shape == 'ribbon'}}"
      class="t-badge__ribbon--after"
      style="{{color ? 'border-color: ' + color : ''}}"
    />
  </view>
  <slot name="count" />
</view>
<wxs src="./badge.wxs" module="_this"/><wxs src="../common/utils.wxs" module="_"/><view style="{{_._style([style, customStyle])}}" class="{{_this.getBadgeOuterClass({shape})}} class {{prefix}}-class" aria-labelledby="{{labelID}}" aria-describedby="{{descriptionID}}" aria-role="{{ ariaRole || 'option'}}"><view id="{{labelID}}" class="{{classPrefix}}__content {{prefix}}-class-content" aria-hidden="true"><slot wx:if="{{!content}}" class="{{classPrefix}}__content-slot"/><text wx:else class="{{classPrefix}}__content-text">{{content}}</text></view><view aria-hidden="true" aria-label="{{ ariaLabel || _.getBadgeAriaLabel({dot, count, maxCount}) }}" wx:if="{{_this.isShowBadge({dot,count,showZero})}}" id="{{descriptionID}}" class="{{_this.getBadgeInnerClass({dot, size, shape, count})}} {{prefix}}-has-count {{prefix}}-class-count" style="{{_._style([_this.getBadgeStyles({color, offset})])}}" aria-hidden="true" aria-label="{{ ariaLabel || _.getBadgeAriaLabel({dot, count, maxCount}) }}">{{ _this.getBadgeValue({dot, count, maxCount}) }}</view><slot name="count"/></view>