breaking change(Picker): update values param

This commit is contained in:
chenjiahan 2020-08-21 00:07:15 +08:00
parent d42b1b43c3
commit af7e7fe9df
3 changed files with 6 additions and 22 deletions

View File

@ -133,3 +133,7 @@ export default {
}, },
}; };
``` ```
### Picker 参数调整
在 Picker 的级联选择下confirm/change 事件返回的回调参数将包含为完整的选项对象。

View File

@ -34,8 +34,6 @@
show-toolbar show-toolbar
:title="t('title')" :title="t('title')"
:columns="t('cascadeColumns')" :columns="t('cascadeColumns')"
@cancel="onCancel"
@confirm="onConfirm"
/> />
</demo-block> </demo-block>

View File

@ -110,16 +110,7 @@ export default createComponent({
if (this.dataType === 'text') { if (this.dataType === 'text') {
this.$emit(event, this.getColumnValue(0), this.getColumnIndex(0)); this.$emit(event, this.getColumnValue(0), this.getColumnIndex(0));
} else { } else {
let values = this.getValues(); this.$emit(event, this.getValues(), this.getIndexes());
// compatible with old version of wrong parameters
// should be removed in next major version
// see: https://github.com/youzan/vant/issues/5905
if (this.dataType === 'cascade') {
values = values.map((item) => item[this.valueKey]);
}
this.$emit(event, values, this.getIndexes());
} }
}, },
@ -151,16 +142,7 @@ export default createComponent({
this.getColumnIndex(0) this.getColumnIndex(0)
); );
} else { } else {
let values = this.getValues(); this.$emit('change', this, this.getValues(), columnIndex);
// compatible with old version of wrong parameters
// should be removed in next major version
// see: https://github.com/youzan/vant/issues/5905
if (this.dataType === 'cascade') {
values = values.map((item) => item[this.valueKey]);
}
this.$emit('change', this, values, columnIndex);
} }
}, },