feat(Cascader): watch value and reset options

This commit is contained in:
chenjiahan
2020-12-20 21:23:50 +08:00
committed by neverland
parent 42d319d478
commit a05da0644b
3 changed files with 87 additions and 28 deletions
+11 -6
View File
@@ -5,12 +5,13 @@
is-link
readonly
:label="t('area')"
:value="base.value"
:value="base.result"
:placeholder="t('selectArea')"
@click="base.show = true"
/>
<van-popup v-model="base.show" round position="bottom">
<van-cascader
v-model="base.value"
:title="t('selectArea')"
:options="t('options')"
@close="base.show = false"
@@ -24,12 +25,13 @@
is-link
readonly
:label="t('area')"
:value="customColor.value"
:value="customColor.result"
:placeholder="t('selectArea')"
@click="customColor.show = true"
/>
<van-popup v-model="customColor.show" round position="bottom">
<van-cascader
v-model="customColor.value"
:title="t('selectArea')"
:options="t('options')"
active-color="#1989fa"
@@ -64,20 +66,23 @@ export default {
base: {
show: false,
value: '',
result: '',
},
customColor: {
show: false,
value: '',
value: null,
result: '',
},
};
},
methods: {
onFinish(type, { selectedOptions }) {
const fieldValue = selectedOptions.map((option) => option.text).join('/');
onFinish(type, { value, selectedOptions }) {
const result = selectedOptions.map((option) => option.text).join('/');
this[type] = {
show: false,
value: fieldValue,
value,
result,
};
},
},