diff --git a/examples/routers/select.vue b/examples/routers/select.vue index dd3143d..0d0b4b0 100644 --- a/examples/routers/select.vue +++ b/examples/routers/select.vue @@ -1,59 +1,46 @@ <template> <div> - <h4>有remote属性</h4> - {{ selectedIds }} - <i-select remote clearable filterable multiple :label="selectedLabel" v-model="selectedIds" style='margin-bottom:20px;'> - <i-option v-for="option in list" :value="option.id" :key="option.id">{{option.name}}</i-option> - </i-select> - <i-button @click="setVal3">设置3</i-button> + <Select v-model="model1" style="width:200px"> + <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option> + </Select> + <Select v-model="model2" style="width:200px"> + <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option> + </Select> </div> </template> <script> export default { data () { return { - list: [], - selectedIds: [], - selectedLabel: [] + cityList: [ + { + value: 'beijing', + label: '北京市' + }, + { + value: 'shanghai', + label: '上海市' + }, + { + value: 'shenzhen', + label: '深圳市' + }, + { + value: 'hangzhou', + label: '杭州市' + }, + { + value: 'nanjing', + label: '南京市' + }, + { + value: 'chongqing', + label: '重庆市' + } + ], + model1: 'beijing', + model2: 'shanghai' } - }, - methods: { - setVal1: function () { - this.selectedLabel = ['几何', '化学']; - this.selectedIds = ['201701041343', '201701011541'] - - }, - setVal2: function () { - this.selectedLabel = ['政治', '英语', '数学']; - this.selectedIds = ['201701031442', '201701061244', '201701011145'] - }, - setVal3: function () { - this.selectedLabel = []; - this.selectedIds = []; - } - }, - mounted () { - setTimeout(() => { - this.list = [{ - name: '语文', - id: '201701011046' - }, { - name: '数学', - id: '201701011145' - }, { - name: '英语', - id: '201701061244' - }, { - name: '几何', - id: '201701041343' - }, { - name: '政治', - id: '201701031442' - }, { - name: '化学', - id: '201701011541' - }] - }, 1000) } } </script> diff --git a/examples/routers/switch.vue b/examples/routers/switch.vue index ebb8c74..fdefaea 100644 --- a/examples/routers/switch.vue +++ b/examples/routers/switch.vue @@ -1,18 +1,18 @@ <template> <div> - <i-switch v-model="m1" :true-value="1" :false-value="0"> + <i-switch v-model="m1" true-value="yes" false-value="no"> <span slot="open">开</span> <span slot="close">关</span> </i-switch> {{ m1 }} - <div @click="m1 = 0">toggle</div> + <div @click="m1 = 'no'">toggle</div> </div> </template> <script> export default { data () { return { - m1: 1 + m1: 'yes' } }, methods: { diff --git a/src/components/switch/switch.vue b/src/components/switch/switch.vue index aa987de..40e367b 100644 --- a/src/components/switch/switch.vue +++ b/src/components/switch/switch.vue @@ -1,8 +1,8 @@ <template> <span :class="wrapClasses" @click="toggle"> <span :class="innerClasses"> - <slot name="open" v-if="currentValue"></slot> - <slot name="close" v-if="!currentValue"></slot> + <slot name="open" v-if="currentValue === trueValue"></slot> + <slot name="close" v-if="currentValue === falseValue"></slot> </span> </span> </template> @@ -48,7 +48,7 @@ return [ `${prefixCls}`, { - [`${prefixCls}-checked`]: this.currentValue, + [`${prefixCls}-checked`]: this.currentValue === this.trueValue, [`${prefixCls}-disabled`]: this.disabled, [`${prefixCls}-${this.size}`]: !!this.size } -- libgit2 0.21.4