美文网首页前端
记一次el-select默认回显问题

记一次el-select默认回显问题

作者: 清酒08 | 来源:发表于2022-06-27 10:59 被阅读0次

在el-select远程搜索中会有个回显问题

就是明明传入了绑定值但是却会显示不出来

解决代码如下

            <el-select
                v-model="ruleForm.selectId"
                filterable
                remote
                ref="select"
                clearable
                reserve-keyword
                placeholder="请输入问卷名称/id进行搜索"
                :remote-method="search">
              <el-option
                  v-for="item in options"
                  :key="item.id"
                  :label="item.title"
                  :value="item.id">
              </el-option>
            </el-select>

在数据初始化的时候将获取到的数据做进一步的处理,进行本地select组件的一个添加

        this.$refs.select.cachedOptions.push({
            currentLabel: currentTitle, //  当前绑定的数据的label
            currentValue: currentId, // 当前绑定数据的value
            label: currentTitle, // 当前绑定的数据的label
            value: currentId // 当前绑定数据的value
        })

单选的同上

相关文章

网友评论

    本文标题:记一次el-select默认回显问题

    本文链接:https://www.haomeiwen.com/subject/pqhbvrtx.html