JSFiddle - React, Tailwind, and code Playground
HTML
<script src="//unpkg.com/vue/dist/vue.js"></script>
<script src="//unpkg.com/element-ui/lib/index.js"></script>
<div id="app">
<el-select
v-model="value9"
filterable
remote
placeholder="请输入关键词"
:remote-method="remoteMethod"
:loading="loading">
<el-option
v-for="item in options4"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</div>
SCSS
@import url("//unpkg.com/element-ui/lib/theme-default/index.css");
Babel + JSX
var Main = {
data() {
return {
options4: [],
value9: "1",
//value9: "Alaska",
list: [],
loading: false,
states: [
{ index: "1", name: "Alabama"},
{ index: "2", name: "Alaska"},
{ index: "3", name: "Arizona"},
{ index: "4", name: "Arkansas"},
{ index: "5", name: "California"},
{ index: "6", name: "Colorado"},
{ index: "7", name: "Connecticut"},
{ index: "8", name: "Delaware"},
{ index: "9", name: "Florida"},
{ index: "10", name: "Georgia"}
]
}
},
mounted() {
this.list = this.states.map(item => {
return { value: item.index, label: item.name };
});
},
methods: {
remoteMethod(query) {
if (query !== '') {
this.loading = true;
setTimeout(() => {
this.loading = false;
this.options4 = this.list.filter(item => {
return item.label.toLowerCase()
.indexOf(query.toLowerCase()) > -1;
});
}, 200);
} else {
this.options4 = [];
}
}
}
}
var Ctor = Vue.extend(Main)
new Ctor().$mount('#app')