form 中有两个菜单,分别是select1和select2,我想实现当select1 选择一个选项后,select2 下拉框的选项会根据select1的选择而改变。以下是实现代码:
{
title: 'select1',
key: 'select1',
type: 'select',
dict: {
value: 'address',
cache: false,
getData: (url, dict, { form, component }) => {
return api.GetAddress().then(ret => { return ret.data })
}
},
search: {
disabled: false,
component: {
props: {
clearable: true
}
}
},
width: 280,
form: {
rules: [
],
component: {
show: true,
span: 12,
props: {
clearable: true
},
placeholder: 'please select one chain'
},
valueChange (key, value, form, { getColumn, mode, component, immediate, getComponent }) {
const template = vm.getEditFormTemplate("select2")
if (!immediate) {
form.select2 = undefined
}
template.component.props = {
dict: {
value: 'func',
cache: false,
getData: (url, dict, { form, component }) => {
return api.GetEvents({ address: form.select1 }).then(ret => { return ret.data })
}
}
}
},
itemProps: {
class: { yxtInput: true }
}
}
}, {
title: 'select2',
key: 'select2',
type: 'select',
show: true,
dict: {
value: 'func',
cache: false,
getData: (url, dict, { form, component }) => {
return api.GetEvents({ address: form.select1 }).then(ret => { return ret.data })
}
},
search: {
disabled: false,
component: {
props: {
clearable: true
}
}
},
width: 180,
form: {
rules: [
],
component: {
span: 12,
show: false,
props: {
clearable: true
},
placeholder: 'please select one chain'
},
valueChange (key, value, form, { getColumn, mode, component, immediate, getComponent }) {
} else {
}
},
itemProps: {
class: { yxtInput: true }
}
}
}
结果,当第一次选择select1的选项时,select2的选项才会随之改变,之后怎么选,select2的选项保持不变,不知道哪里出了问题,有知道的大神么?
什么组件呀?
@bauer
@hongzai 好的,我研究下