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

    }

相关推荐
ConardLi14 小时前
把 Claude Design 做成 Skill,你的网站也能拥有顶级视觉体验
前端·人工智能·后端
We་ct14 小时前
LeetCode 120. 三角形最小路径和:动态规划详解
前端·javascript·算法·leetcode·typescript·动态规划
IT_陈寒14 小时前
React状态更新那点事儿,我掉坑里爬了半天
前端·人工智能·后端
cwxcc15 小时前
Google Core Web Vitals(核心网页指标)
前端·性能优化
|晴 天|15 小时前
Vue 3 + LocalStorage 实现博客游戏化系统:成就墙、每日签到、积分商城
前端·vue.js·游戏
逾明15 小时前
Claude Code及Codex的MCP安装和Mastergo MCP的使用
前端·mcp
LovroMance16 小时前
如何进行组件封装
前端
難釋懷16 小时前
Redis服务器端优化-慢查询优化
前端·redis·bootstrap
sghuter16 小时前
Chrome如何重塑Web标准未来
前端·chrome
渣渣xiong16 小时前
从零开始:前端转型AI agent直到就业第十四天-第十七天
前端·人工智能