mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
Merge pull request #5185 from maoweifan/dev
fix(Cascader): fix selected style error and fieldNames Invalid
This commit is contained in:
commit
9c57499824
packages/cascader
@ -37,14 +37,14 @@
|
||||
wx:for="{{ tab.options }}"
|
||||
wx:for-item="option"
|
||||
wx:key="index"
|
||||
class="{{ option.className }} {{ utils.optionClass(tab, textKey, option) }}"
|
||||
style="{{ utils.optionStyle({ tab, textKey, option, activeColor }) }}"
|
||||
class="{{ option.className }} {{ utils.optionClass(tab, valueKey, option) }}"
|
||||
style="{{ utils.optionStyle({ tab, valueKey, option, activeColor }) }}"
|
||||
data-option="{{ option }}"
|
||||
data-tab-index="{{ tabIndex }}"
|
||||
bind:tap="onSelect"
|
||||
>
|
||||
<text>{{ option[textKey] }}</text>
|
||||
<van-icon wx:if="{{ utils.isSelected(tab, textKey, option) }}" name="success" size="18" />
|
||||
<van-icon wx:if="{{ utils.isSelected(tab, valueKey, option) }}" name="success" size="18" />
|
||||
</view>
|
||||
</view>
|
||||
<!-- 暂不支持 -->
|
||||
|
@ -1,16 +1,16 @@
|
||||
var utils = require('../wxs/utils.wxs');
|
||||
var style = require('../wxs/style.wxs');
|
||||
|
||||
function isSelected(tab, textKey, option) {
|
||||
return tab.selected && tab.selected[textKey] === option[textKey]
|
||||
function isSelected(tab, valueKey, option) {
|
||||
return tab.selected && tab.selected[valueKey] === option[valueKey]
|
||||
}
|
||||
|
||||
function optionClass(tab, textKey, option) {
|
||||
return utils.bem('cascader__option', { selected: isSelected({ tab, textKey, option }), disabled: option.disabled })
|
||||
function optionClass(tab, valueKey, option) {
|
||||
return utils.bem('cascader__option', { selected: isSelected(tab, valueKey, option), disabled: option.disabled })
|
||||
}
|
||||
|
||||
function optionStyle(data) {
|
||||
var color = data.option.color || (isSelected(data.tab, data.textKey, data.option) ? data.activeColor : undefined);
|
||||
var color = data.option.color || (isSelected(data.tab, data.valueKey, data.option) ? data.activeColor : undefined);
|
||||
return style({
|
||||
color
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user