5 下拉二级菜只有在第一次选择时联动,之后二级菜单选项就保持不变 悬赏已过期

发布于 2022-09-11 17:50:48

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的选项保持不变,不知道哪里出了问题,有知道的大神么?

查看更多

关注者
0
被浏览
808
1 个回答
hongzai
hongzai 认证专家 2022-09-12
life is coding,外包,远程协助,咨询添加微信:H0nGzA1

多级联动有组件的,好像并不是select,只用传数据就行了

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览