element ui - smile0821/learngit GitHub Wiki

var Main = { data() { return { change:[], options: [], value: [], list: [], loading: false, states: ["Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming"] } }, mounted() { this.list = this.states.map(item => { let test = { name: item, state: item }; return { value: JSON.stringify(test), label: item }; }); }, methods: { remoteMethod(query) { if (query !== '') { this.loading = true; setTimeout(() => { this.loading = false; this.options = this.list.filter(item => { return item.label.toLowerCase() .indexOf(query.toLowerCase()) > -1; }); }, 200); } else { this.options = []; } }, clickItem(){ for(let i=0;i<this.value.length;i++){ if(i<5){ // alert(this.value[i].label+":" // +this.value[i].value); alert(this.value[i]); let s = JSON.parse(this.value[i]); this.change.push(s); } } for(let j=0;j<=this.change.length;j++){ if(this.change[j]){ alert("change:"+this.change[j].name+"::"+this.change[j].state);
} } } } } var Ctor = Vue.extend(Main) new Ctor().$mount('#app')