mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-24 18:36:51 +08:00
fix(Cascader): failed to switch to active tab
This commit is contained in:
parent
5fc1a8a06e
commit
f71a1da8a7
@ -3,15 +3,18 @@ import Tab from '../tab';
|
|||||||
import Tabs from '../tabs';
|
import Tabs from '../tabs';
|
||||||
import Icon from '../icon';
|
import Icon from '../icon';
|
||||||
|
|
||||||
const [createComponent, bem] = createNamespace('cascader');
|
const [createComponent, bem, t] = createNamespace('cascader');
|
||||||
|
|
||||||
export default createComponent({
|
export default createComponent({
|
||||||
props: {
|
props: {
|
||||||
title: String,
|
title: String,
|
||||||
value: [Number, String],
|
value: [Number, String],
|
||||||
options: Array,
|
|
||||||
placeholder: String,
|
placeholder: String,
|
||||||
activeColor: String,
|
activeColor: String,
|
||||||
|
options: {
|
||||||
|
type: Array,
|
||||||
|
default: () => [],
|
||||||
|
},
|
||||||
closeable: {
|
closeable: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
@ -99,7 +102,9 @@ export default createComponent({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.activeTab = this.tabs.length - 1;
|
this.$nextTick(() => {
|
||||||
|
this.activeTab = this.tabs.length - 1;
|
||||||
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -137,10 +142,14 @@ export default createComponent({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const selectedOptions = this.tabs
|
||||||
|
.map((tab) => tab.selectedOption)
|
||||||
|
.filter((item) => !!item);
|
||||||
|
|
||||||
const eventParams = {
|
const eventParams = {
|
||||||
value: option.value,
|
value: option.value,
|
||||||
tabIndex,
|
tabIndex,
|
||||||
selectedOptions: this.tabs.map((tab) => tab.selectedOption),
|
selectedOptions,
|
||||||
};
|
};
|
||||||
this.$emit('input', option.value);
|
this.$emit('input', option.value);
|
||||||
this.$emit('change', eventParams);
|
this.$emit('change', eventParams);
|
||||||
@ -197,7 +206,7 @@ export default createComponent({
|
|||||||
const { options, selectedOption } = item;
|
const { options, selectedOption } = item;
|
||||||
const title = selectedOption
|
const title = selectedOption
|
||||||
? selectedOption.text
|
? selectedOption.text
|
||||||
: this.placeholder || this.t('select');
|
: this.placeholder || t('select');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tab
|
<Tab
|
||||||
|
Loading…
x
Reference in New Issue
Block a user