el-select可输入限制输入的字数

el-select创建条目以及远程搜索

复制代码
            <el-select
              v-model="form.constructionName"
              placeholder="请输入"
              style="width: 400px"
              allow-create
              default-first-option
              filterable
              remote
              reserve-keyword
              :remote-method="remoteMethod1"
              :loading="loading"
              ref="sgSelect"
              @input.native="sgfilterData"
            >
              <el-option
                v-for="item in constructionoptions"
                :key="item.name"
                :label="item.name"
                :value="item.name"
              >
              </el-option>
            </el-select>

限制下拉框输入字数

  1. ref="sgSelect"

  2. @input.native="sgfilterData"

  3. 如下方法,就over了

    methods:{
    sgfilterData() {
    var str = this.refs.sgSelect.data.selectedLabel; // 此属性得到输入的文字
    // 控制的js
    if (str.length > 20) {
    this.refs.sgSelect.data.selectedLabel = str.substr(0, 20);
    }
    },

    }

相关推荐
Penge6669 小时前
《Go 后端开发者学 TypeScript:数组和元组》
javascript
Penge6669 小时前
《Go 后端开发者学 TypeScript:export关键字大全》
javascript
Penge66610 小时前
《Go 后端开发者学 TypeScript:从零理解 async、await 与 Promise》
javascript
Penge66610 小时前
typescript 中const用法
javascript
Csvn10 小时前
Monorepo
前端
Csvn10 小时前
流水线
前端
Csvn10 小时前
微前端架构
前端
Linux-lucky12 小时前
45-Linux学习之旅之防火墙与WEB加固
linux·前端·网络·学习·ubuntu
风骏时光牛马14 小时前
生成一个移动端标题,只需要一个标题,不需要其他的任何文本。
前端
IT_陈寒15 小时前
Redis雪崩把我坑惨了,这是5年经验的教训
前端·人工智能·后端