vue3当select查询参数变化时界面不响应

   {
        prop: "ukey",
        label: "证券代码",
        mold: "bond",
        moldProps: {
          valueKey: "marketCode",
          labelKey: "marketAbbr",
          queryKey: "keyWord",
          queryUrl: querySecurity,
          queryParam: {
            marketId: tractMarketId.value, // 绑定动态 marketId
            }
          onSelectChange: handleBondChange,
        },
        clearable: true,
        required: true,
        itemVisible: [1].includes(currentItem.value.scopeSecu),
      },
        {
        prop: "tractId",
        label: "交易账户",
        filterable: true,
        mold: "select",
        moldProps: {
          labelKey: ["tractCode", "tractName"],
          valueKey: "tractId",
          labelSeparator: "\u00A0\u00A0",
          options: options.authorityTract,
          onSelectChange: (val) => handleTractIdChange(val),
        },
        clearable: true,
        itemVisible: [2].includes(currentItem.value.scopeAcc),
        required: true,
      },



  let tractMarketId = ref("");
  function handleTractIdChange(val) {
    const result = options.authorityTract.find((item) => item.tractId === val);
    if (result) {
      tractMarketId.value = result.marketId;
    }
  }

可以看出当交易账户单选框点击变化的时候tractMarketId 也会随之变化,同时参数queryParam也会变化
这个时候会出现VUE渲染不及时
会清空dialog中的所有的值

解决方法:

queryParam: computed(() => ({
            marketId: tractMarketId.value, // 绑定动态 marketId
          })),

使用computed动态绑定queryParam 当值变化的时候自动更新queryPaream的传参

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值