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);
    }
    },

    }

相关推荐
小狼154542 小时前
浏览器扩展脚本为什么有时候不生效:注入时机、iframe 和单页路由,多多开票助手
前端·chrome
じòぴé南冸じょうげん2 小时前
油猴脚本突然发现变成灰色了,无法使用?页面不生效?刷新页面没反应?
前端
Csvn4 小时前
组合式 API(Composition API)
前端
火柴就是我5 小时前
Android 打包报错 25.0.3
android·前端
BD_Marathon5 小时前
消息对象中字段的说明
java·前端·python
八荒启·交互动画5 小时前
Web特效025—用 Canvas 2D 做Web特效的定义与边界:这支画笔能做到哪一步
前端·webgl·网页特效·八荒启-交互动画·八荒启
Ai-_Man5 小时前
您您这可以把Dola的多个会话比如说。左侧的多个会话一次性导出吗?不是单条会话里面的多次会对话。用AI导出鸭,答案是可以的
开发语言·前端·人工智能·小程序
excel6 小时前
Nuxt 中使用 useHead 优化 SEO 与 GEO
前端
IT_陈寒7 小时前
SpringBoot启动慢得像蜗牛?原来是这个配置在捣鬼
前端·人工智能·后端
计算机魔术师7 小时前
Muse Spark跑赢Gemini,但真正的底牌是这种设计
前端