学无先后,达者为师

网站首页 前端文档 正文

限制element UI el-select输入内容的长度

作者:它经不起推敲的 更新时间: 2021-12-18 前端文档
             <el-select
                v-model="item.couponRandomId"
                filterable
                :id="`searchSelect${index}`"
                remote
                reserve-keyword
                placeholder="请输入"
                ref="searchSelect"
                :class="{ coupon: !item.couponRandomId }"
                :remote-method="remoteMethod"
                :loading="loading"
                style="width: 230px"
              >
                <el-option
                  v-for="item in options"
                  :key="item"
                  :label="item"
                  :value="item"
                >
                </el-option>
              </el-select>

methods中

  watch: {
    "editForms.list": function () {
      this.$nextTick(() => {
        this.addDom();
      });
    },
  },
  addDom() {
      this.editForms.list.forEach((item, index) => {
        let input = document.querySelector(`#searchSelect${index}`);
        if (input) {
          input.setAttribute("maxLength", 8);
        }
      });
    },

原文链接:https://blog.csdn.net/m0_46365130/article/details/122107749

栏目分类
最近更新