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>
限制下拉框输入字数
-
ref="sgSelect"
-
@input.native="sgfilterData"
-
如下方法,就over了
methods:{
sgfilterData() {
var str = this.refs.sgSelect.data.selectedLabel; // 此属性得到输入的文字
// 控制的js
if (str.length > 20) {
this.refs.sgSelect.data.selectedLabel = str.substr(0, 20);
}
},}