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
@ -37,14 +37,14 @@
|
|||||||
wx:for="{{ tab.options }}"
|
wx:for="{{ tab.options }}"
|
||||||
wx:for-item="option"
|
wx:for-item="option"
|
||||||
wx:key="index"
|
wx:key="index"
|
||||||
class="{{ option.className }} {{ utils.optionClass(tab, textKey, option) }}"
|
class="{{ option.className }} {{ utils.optionClass(tab, valueKey, option) }}"
|
||||||
style="{{ utils.optionStyle({ tab, textKey, option, activeColor }) }}"
|
style="{{ utils.optionStyle({ tab, valueKey, option, activeColor }) }}"
|
||||||
data-option="{{ option }}"
|
data-option="{{ option }}"
|
||||||
data-tab-index="{{ tabIndex }}"
|
data-tab-index="{{ tabIndex }}"
|
||||||
bind:tap="onSelect"
|
bind:tap="onSelect"
|
||||||
>
|
>
|
||||||
<text>{{ option[textKey] }}</text>
|
<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>
|
||||||
</view>
|
</view>
|
||||||
<!-- 暂不支持 -->
|
<!-- 暂不支持 -->
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
var utils = require('../wxs/utils.wxs');
|
var utils = require('../wxs/utils.wxs');
|
||||||
var style = require('../wxs/style.wxs');
|
var style = require('../wxs/style.wxs');
|
||||||
|
|
||||||
function isSelected(tab, textKey, option) {
|
function isSelected(tab, valueKey, option) {
|
||||||
return tab.selected && tab.selected[textKey] === option[textKey]
|
return tab.selected && tab.selected[valueKey] === option[valueKey]
|
||||||
}
|
}
|
||||||
|
|
||||||
function optionClass(tab, textKey, option) {
|
function optionClass(tab, valueKey, option) {
|
||||||
return utils.bem('cascader__option', { selected: isSelected({ tab, textKey, option }), disabled: option.disabled })
|
return utils.bem('cascader__option', { selected: isSelected(tab, valueKey, option), disabled: option.disabled })
|
||||||
}
|
}
|
||||||
|
|
||||||
function optionStyle(data) {
|
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({
|
return style({
|
||||||
color
|
color
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user