element messagebox 搭配el-select

文章描述了一个在Vue应用中使用$nextTick更新组件状态的问题,特别是在el-select组件中遇到的回显和ref绑定异常。在change事件处理函数中,作者尝试了更新select的值,导致了一些偶发的bug。用户在确认对话框中选择流程节点进行重置操作时,如果未选择节点会显示警告,已选择则调用接口重启流程。
摘要由CSDN通过智能技术生成

在这里插入图片描述

this.$nextTick(() => {
              const h = this.$createElement;
              const that = this
              that.selectVal = ''
              this.$msgbox({
                title: "请选择将要重置的流程节点",
                message: h('el-select',
                  {
                    ref: 'selectView',
                    props: {
                      value: that.selectVal,
                      filterable: true,
                    }, 
                    on: {
                      change: e => {
                        that.selectVal = e
						// 会遇到两种问题 如下图
                        that.$refs.selectView.value = e // select下拉框值改变,回显到页面上

                      },
                    },
                  },
                  [
                    this.wfNodeIdOptions.map(it => {
                      return h('el-option', {
                        props: {
                          label: it.name,
                          key: it.id,
                          value: it.id,
                        },
                      });
                    })
                  ]
                ),
                showCancelButton: true,
                closeOnClickModal: false,
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                beforeClose: (action, instance, done) => {
                  if (action === 'confirm') {
                    if (that.selectVal) {
                      done();
                      this.tableLoading = true;
                      jxApi.batchRestart(checkedRows, this.useObject, that.selectVal, (res) => {
                        this.tableLoading = false;
                        if (res.meta.success) {
                          this.$message({
                            message: "重启成功",
                            type: "success",
                          });
                          this.$refs.table.doAjax();
                        }
                      });
                    } else {
                      this.$message.warning('请选择将要重置的流程节点')
                    }
                  } else {
                    done();
                  }
                }
              }).then(action => {
                this.$refs.table.doAjax();
              }).catch(e => { });
            })

onChange事件bug:

如果没有这行代码,that.$refs.selectView.value = e下拉框回显不了
但是有了后存在下面第一种问题,当页面切换进来时,下拉选择提示ref绑定不上。
在这里插入图片描述
就算绑定上了,也会提示下面的错误
在这里插入图片描述
第二个错误还将就用,主要是第一个错误解决不了会出现偶发的bug,谁能救救我

评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值