fix: [el-cascader] multiple search with v-model can't work (#3350)

Co-authored-by: Kevin <sxzz@sxzz.moe>
This commit is contained in:
Alan Wang 2021-09-15 05:25:08 +08:00 committed by GitHub
parent be58b742ef
commit 5978ebdabd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -100,23 +100,36 @@ export default defineComponent({
)
const renderLabelFn = computed(() => props.renderLabel || slots.default)
let oldConfig: typeof config
let oldOptions: CascaderOption[]
const initStore = () => {
const { options } = props
const cfg = config.value
manualChecked = false
store.value = new Store(options, cfg)
menus.value = [store.value.getNodes()]
const configTemp = config
if (
oldOptions === undefined ||
oldOptions !== options ||
oldConfig === undefined ||
configTemp !== oldConfig
) {
manualChecked = false
store.value = new Store(options, cfg)
menus.value = [store.value.getNodes()]
if (cfg.lazy && isEmpty(props.options)) {
initialLoaded = false
lazyLoad(null, () => {
initialLoaded = true
if (cfg.lazy && isEmpty(props.options)) {
initialLoaded = false
lazyLoad(null, () => {
initialLoaded = true
syncCheckedValue(false, true)
})
} else {
syncCheckedValue(false, true)
})
} else {
syncCheckedValue(false, true)
}
}
oldConfig = configTemp
oldOptions = options
}
const lazyLoad: ElCascaderPanelContext['lazyLoad'] = (node, cb) => {
@ -322,7 +335,7 @@ export default defineComponent({
})
)
watch([config, () => props.options], initStore, {
watch([config, () => props.options], () => initStore(), {
deep: true,
immediate: true,
})