Skip to content

Commit

Permalink
fix(switch): resolve label and icon (#1809)
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeJim authored Mar 18, 2023
1 parent cba42b0 commit 7826aed
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/switch/__test__/__snapshots__/demo.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ exports[`Switch Switch label demo works fine 1`] = `
<t-switch
label="{{
Array [
"关",
"开",
"",
]
}}"
slot="note"
Expand All @@ -57,8 +57,8 @@ exports[`Switch Switch label demo works fine 1`] = `
defaultValue="{{true}}"
icon="{{
Array [
"close",
"check",
"close",
]
}}"
slot="note"
Expand Down
2 changes: 1 addition & 1 deletion src/switch/__test__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe('switch', () => {
't-switch': switchComp,
},
data: {
label: ['', ''],
label: ['', ''],
},
});
const comp = simulate.render(id);
Expand Down
4 changes: 2 additions & 2 deletions src/switch/_example/label/index.wxml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<t-cell title="带文字开关">
<t-switch bindchange="handleChange" value="{{defaultVal}}" label="{{['', '']}}" slot="note" />
<t-switch bindchange="handleChange" value="{{defaultVal}}" label="{{['', '']}}" slot="note" />
</t-cell>

<t-cell title="带图标开关" bordered="{{false}}">
<t-switch defaultValue="{{true}}" icon="{{['close', 'check']}}" slot="note" />
<t-switch defaultValue="{{true}}" icon="{{['check', 'close']}}" slot="note" />
</t-cell>
4 changes: 2 additions & 2 deletions src/switch/switch.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
class="{{_.cls(classPrefix + '__label', [['checked', checked], ['disabled', disabled], size])}} {{prefix}}-class-label"
>
<t-loading wx:if="{{loading}}" inherit-color size="32rpx" />
<text wx:elif="{{label.length == 2}}">{{checked ? label[1] : label[0]}}</text>
<text wx:elif="{{label.length == 2}}">{{checked ? label[0] : label[1]}}</text>
<t-icon
wx:elif="{{icon.length == 2}}"
name="{{checked ? icon[1] : icon[0]}}"
name="{{checked ? icon[0] : icon[1]}}"
t-class="{{_.cls(classPrefix + '__icon', [['checked', checked], size])}}"
/>
</view>
Expand Down

0 comments on commit 7826aed

Please sign in to comment.