Commit 219e5c925147a29f858353c2c4297262b82e86b0
1 parent
03a90452
fixed #957
Showing
2 changed files
with
159 additions
and
92 deletions
Show diff stats
examples/routers/select.vue
| 1 | +<!--<template>--> | |
| 2 | + <!--<Row>--> | |
| 3 | + <!--<i-col span="4">{{model}}</i-col>--> | |
| 4 | + <!--<i-col span="8">--> | |
| 5 | + <!--<i-select v-model="model" :label="['L Alabama', 'L Hawaii']" multiple @input="handleInput" filterable remote :remote-method="remoteMethod" :loading="loading" clearable>--> | |
| 6 | + <!--<i-option v-for="option in options" :value="option.value" :key="new Date()">{{option.label}}</i-option>--> | |
| 7 | + <!--</i-select>--> | |
| 8 | + <!--</i-col>--> | |
| 9 | + <!--</Row>--> | |
| 10 | +<!--</template>--> | |
| 11 | + | |
| 12 | +<!--<script>--> | |
| 13 | + <!--export default {--> | |
| 14 | + <!--data () {--> | |
| 15 | + <!--return {--> | |
| 16 | +<!--// model: 'Alabama',--> | |
| 17 | + <!--model: ['Alabama', 'Hawaii'],--> | |
| 18 | + <!--options: [--> | |
| 19 | + | |
| 20 | + <!--],--> | |
| 21 | + <!--list: [],--> | |
| 22 | + <!--loading: false,--> | |
| 23 | + <!--states: ["Al", "Alabama", "Alaska", "Arizona",--> | |
| 24 | + <!--"Arkansas", "California", "Colorado",--> | |
| 25 | + <!--"Connecticut", "Delaware", "Florida",--> | |
| 26 | + <!--"Georgia", "Hawaii", "Idaho", "Illinois",--> | |
| 27 | + <!--"Indiana", "Iowa", "Kansas", "Kentucky",--> | |
| 28 | + <!--"Louisiana", "Maine", "Maryland",--> | |
| 29 | + <!--"Massachusetts", "Michigan", "Minnesota",--> | |
| 30 | + <!--"Mississippi", "Missouri", "Montana",--> | |
| 31 | + <!--"Nebraska", "Nevada", "New Hampshire",--> | |
| 32 | + <!--"New Jersey", "New Mexico", "New York",--> | |
| 33 | + <!--"North Carolina", "North Dakota", "Ohio",--> | |
| 34 | + <!--"Oklahoma", "Oregon", "Pennsylvania",--> | |
| 35 | + <!--"Rhode Island", "South Carolina",--> | |
| 36 | + <!--"South Dakota", "Tennessee", "Texas",--> | |
| 37 | + <!--"Utah", "Vermont", "Virginia",--> | |
| 38 | + <!--"Washington", "West Virginia", "Wisconsin",--> | |
| 39 | + <!--"Wyoming"]--> | |
| 40 | + <!--}--> | |
| 41 | + <!--},--> | |
| 42 | + <!--mounted () {--> | |
| 43 | + <!--this.options = [--> | |
| 44 | +<!--// {--> | |
| 45 | +<!--// label: '全部',--> | |
| 46 | +<!--// value: 0--> | |
| 47 | +<!--// },{--> | |
| 48 | +<!--// label: '苹果',--> | |
| 49 | +<!--// value: 1--> | |
| 50 | +<!--// },{--> | |
| 51 | +<!--// label: '香蕉',--> | |
| 52 | +<!--// value: 2--> | |
| 53 | +<!--// },{--> | |
| 54 | +<!--// label: '西瓜',--> | |
| 55 | +<!--// value: 3--> | |
| 56 | +<!--// }--> | |
| 57 | + <!--];--> | |
| 58 | + <!--},--> | |
| 59 | + <!--methods: {--> | |
| 60 | + <!--handleAdd () {--> | |
| 61 | + <!--this.options = [--> | |
| 62 | + <!--{--> | |
| 63 | + <!--label: '全部',--> | |
| 64 | + <!--value: 0--> | |
| 65 | + <!--},{--> | |
| 66 | + <!--label: '苹果',--> | |
| 67 | + <!--value: 1--> | |
| 68 | + <!--},{--> | |
| 69 | + <!--label: '香蕉',--> | |
| 70 | + <!--value: 2--> | |
| 71 | + <!--},{--> | |
| 72 | + <!--label: '西瓜',--> | |
| 73 | + <!--value: 3--> | |
| 74 | + <!--}--> | |
| 75 | + <!--]--> | |
| 76 | + <!--},--> | |
| 77 | + <!--remoteMethod (query) {--> | |
| 78 | + <!--console.log(13)--> | |
| 79 | + <!--if (query !== '') {--> | |
| 80 | + <!--this.loading = true;--> | |
| 81 | + <!--setTimeout(() => {--> | |
| 82 | + <!--this.loading = false;--> | |
| 83 | + <!--this.options = this.list.filter(item => {--> | |
| 84 | + <!--return item.label.toLowerCase()--> | |
| 85 | + <!--.indexOf(query.toLowerCase()) > -1;--> | |
| 86 | + <!--});--> | |
| 87 | + <!--}, 500);--> | |
| 88 | + <!--} else {--> | |
| 89 | + <!--this.options = [];--> | |
| 90 | + <!--}--> | |
| 91 | + <!--},--> | |
| 92 | + <!--handleInput () {--> | |
| 93 | +<!--// console.log(1)--> | |
| 94 | + <!--}--> | |
| 95 | + <!--},--> | |
| 96 | + <!--mounted () {--> | |
| 97 | + <!--this.list = this.states.map(item => {--> | |
| 98 | + <!--return {--> | |
| 99 | + <!--value: item,--> | |
| 100 | + <!--label: 'L ' + item--> | |
| 101 | + <!--};--> | |
| 102 | + <!--});--> | |
| 103 | + <!--}--> | |
| 104 | + <!--}--> | |
| 105 | +<!--</script>--> | |
| 106 | + | |
| 107 | + | |
| 1 | 108 | <template> |
| 2 | - <Row> | |
| 3 | - <i-col span="4">{{model}}</i-col> | |
| 4 | - <i-col span="8"> | |
| 5 | - <i-select v-model="model" :label="['L Alabama', 'L Hawaii']" multiple @input="handleInput" filterable remote :remote-method="remoteMethod" :loading="loading" clearable> | |
| 6 | - <i-option v-for="option in options" :value="option.value" :key="new Date()">{{option.label}}</i-option> | |
| 7 | - </i-select> | |
| 8 | - </i-col> | |
| 9 | - </Row> | |
| 109 | + <div> | |
| 110 | + <Row style="width: 400px;"> | |
| 111 | + <i-col span="12" style="padding-right:10px"> | |
| 112 | + <Select v-model="model11" filterable> | |
| 113 | + <Option v-for="item in cityList" :value="item.value" :key="item">{{ item.label }}</Option> | |
| 114 | + </Select> | |
| 115 | + </i-col> | |
| 116 | + <i-col span="12"> | |
| 117 | + <Select v-model="model12" filterable multiple> | |
| 118 | + <Option v-for="item in cityList" :value="item.value" :key="item">{{ item.label }}</Option> | |
| 119 | + </Select> | |
| 120 | + </i-col> | |
| 121 | + </Row> | |
| 122 | + <Button @click="handleSet">set</Button> | |
| 123 | + </div> | |
| 10 | 124 | </template> |
| 11 | - | |
| 12 | 125 | <script> |
| 13 | 126 | export default { |
| 14 | 127 | data () { |
| 15 | 128 | return { |
| 16 | -// model: 'Alabama', | |
| 17 | - model: ['Alabama', 'Hawaii'], | |
| 18 | - options: [ | |
| 19 | - | |
| 129 | + cityList: [ | |
| 130 | + { | |
| 131 | + value: 'beijing', | |
| 132 | + label: '北京市' | |
| 133 | + }, | |
| 134 | + { | |
| 135 | + value: 'shanghai', | |
| 136 | + label: '上海市' | |
| 137 | + }, | |
| 138 | + { | |
| 139 | + value: 'shenzhen', | |
| 140 | + label: '深圳市' | |
| 141 | + }, | |
| 142 | + { | |
| 143 | + value: 'hangzhou', | |
| 144 | + label: '杭州市' | |
| 145 | + }, | |
| 146 | + { | |
| 147 | + value: 'nanjing', | |
| 148 | + label: '南京市' | |
| 149 | + }, | |
| 150 | + { | |
| 151 | + value: 'chongqing', | |
| 152 | + label: '重庆市' | |
| 153 | + } | |
| 20 | 154 | ], |
| 21 | - list: [], | |
| 22 | - loading: false, | |
| 23 | - states: ["Al", "Alabama", "Alaska", "Arizona", | |
| 24 | - "Arkansas", "California", "Colorado", | |
| 25 | - "Connecticut", "Delaware", "Florida", | |
| 26 | - "Georgia", "Hawaii", "Idaho", "Illinois", | |
| 27 | - "Indiana", "Iowa", "Kansas", "Kentucky", | |
| 28 | - "Louisiana", "Maine", "Maryland", | |
| 29 | - "Massachusetts", "Michigan", "Minnesota", | |
| 30 | - "Mississippi", "Missouri", "Montana", | |
| 31 | - "Nebraska", "Nevada", "New Hampshire", | |
| 32 | - "New Jersey", "New Mexico", "New York", | |
| 33 | - "North Carolina", "North Dakota", "Ohio", | |
| 34 | - "Oklahoma", "Oregon", "Pennsylvania", | |
| 35 | - "Rhode Island", "South Carolina", | |
| 36 | - "South Dakota", "Tennessee", "Texas", | |
| 37 | - "Utah", "Vermont", "Virginia", | |
| 38 | - "Washington", "West Virginia", "Wisconsin", | |
| 39 | - "Wyoming"] | |
| 155 | + model11: '', | |
| 156 | + model12: [] | |
| 40 | 157 | } |
| 41 | 158 | }, |
| 42 | - mounted () { | |
| 43 | - this.options = [ | |
| 44 | -// { | |
| 45 | -// label: '全部', | |
| 46 | -// value: 0 | |
| 47 | -// },{ | |
| 48 | -// label: '苹果', | |
| 49 | -// value: 1 | |
| 50 | -// },{ | |
| 51 | -// label: '香蕉', | |
| 52 | -// value: 2 | |
| 53 | -// },{ | |
| 54 | -// label: '西瓜', | |
| 55 | -// value: 3 | |
| 56 | -// } | |
| 57 | - ]; | |
| 58 | - }, | |
| 59 | 159 | methods: { |
| 60 | - handleAdd () { | |
| 61 | - this.options = [ | |
| 62 | - { | |
| 63 | - label: '全部', | |
| 64 | - value: 0 | |
| 65 | - },{ | |
| 66 | - label: '苹果', | |
| 67 | - value: 1 | |
| 68 | - },{ | |
| 69 | - label: '香蕉', | |
| 70 | - value: 2 | |
| 71 | - },{ | |
| 72 | - label: '西瓜', | |
| 73 | - value: 3 | |
| 74 | - } | |
| 75 | - ] | |
| 76 | - }, | |
| 77 | - remoteMethod (query) { | |
| 78 | - console.log(13) | |
| 79 | - if (query !== '') { | |
| 80 | - this.loading = true; | |
| 81 | - setTimeout(() => { | |
| 82 | - this.loading = false; | |
| 83 | - this.options = this.list.filter(item => { | |
| 84 | - return item.label.toLowerCase() | |
| 85 | - .indexOf(query.toLowerCase()) > -1; | |
| 86 | - }); | |
| 87 | - }, 500); | |
| 88 | - } else { | |
| 89 | - this.options = []; | |
| 90 | - } | |
| 91 | - }, | |
| 92 | - handleInput () { | |
| 93 | -// console.log(1) | |
| 160 | + handleSet () { | |
| 161 | + this.model11 = 'shanghai'; | |
| 162 | +// this.model12 = ['beijing']; | |
| 94 | 163 | } |
| 95 | - }, | |
| 96 | - mounted () { | |
| 97 | - this.list = this.states.map(item => { | |
| 98 | - return { | |
| 99 | - value: item, | |
| 100 | - label: 'L ' + item | |
| 101 | - }; | |
| 102 | - }); | |
| 103 | 164 | } |
| 104 | 165 | } |
| 105 | -</script> | |
| 106 | 166 | \ No newline at end of file |
| 167 | +</script> | ... | ... |
src/components/select/select.vue