Commit 1f41c9ca2c45a13747b5fa8201c4e4481f409a36

Authored by 梁灏
1 parent 6f719603

fixed #1797

examples/routers/select.vue
1 1 <template>
2 2 <div>
3   - <h4>有remote属性</h4>
4   - {{ selectedIds }}
5   - <i-select remote clearable filterable multiple :label="selectedLabel" v-model="selectedIds" style='margin-bottom:20px;'>
6   - <i-option v-for="option in list" :value="option.id" :key="option.id">{{option.name}}</i-option>
7   - </i-select>
8   - <i-button @click="setVal3">设置3</i-button>
  3 + <Select v-model="model1" style="width:200px">
  4 + <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
  5 + </Select>
  6 + <Select v-model="model2" style="width:200px">
  7 + <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
  8 + </Select>
9 9 </div>
10 10 </template>
11 11 <script>
12 12 export default {
13 13 data () {
14 14 return {
15   - list: [],
16   - selectedIds: [],
17   - selectedLabel: []
  15 + cityList: [
  16 + {
  17 + value: 'beijing',
  18 + label: '北京市'
  19 + },
  20 + {
  21 + value: 'shanghai',
  22 + label: '上海市'
  23 + },
  24 + {
  25 + value: 'shenzhen',
  26 + label: '深圳市'
  27 + },
  28 + {
  29 + value: 'hangzhou',
  30 + label: '杭州市'
  31 + },
  32 + {
  33 + value: 'nanjing',
  34 + label: '南京市'
  35 + },
  36 + {
  37 + value: 'chongqing',
  38 + label: '重庆市'
  39 + }
  40 + ],
  41 + model1: 'beijing',
  42 + model2: 'shanghai'
18 43 }
19   - },
20   - methods: {
21   - setVal1: function () {
22   - this.selectedLabel = ['几何', '化学'];
23   - this.selectedIds = ['201701041343', '201701011541']
24   -
25   - },
26   - setVal2: function () {
27   - this.selectedLabel = ['政治', '英语', '数学'];
28   - this.selectedIds = ['201701031442', '201701061244', '201701011145']
29   - },
30   - setVal3: function () {
31   - this.selectedLabel = [];
32   - this.selectedIds = [];
33   - }
34   - },
35   - mounted () {
36   - setTimeout(() => {
37   - this.list = [{
38   - name: '语文',
39   - id: '201701011046'
40   - }, {
41   - name: '数学',
42   - id: '201701011145'
43   - }, {
44   - name: '英语',
45   - id: '201701061244'
46   - }, {
47   - name: '几何',
48   - id: '201701041343'
49   - }, {
50   - name: '政治',
51   - id: '201701031442'
52   - }, {
53   - name: '化学',
54   - id: '201701011541'
55   - }]
56   - }, 1000)
57 44 }
58 45 }
59 46 </script>
... ...
examples/routers/switch.vue
1 1 <template>
2 2 <div>
3   - <i-switch v-model="m1" :true-value="1" :false-value="0">
  3 + <i-switch v-model="m1" true-value="yes" false-value="no">
4 4 <span slot="open">开</span>
5 5 <span slot="close">关</span>
6 6 </i-switch>
7 7 {{ m1 }}
8   - <div @click="m1 = 0">toggle</div>
  8 + <div @click="m1 = 'no'">toggle</div>
9 9 </div>
10 10 </template>
11 11 <script>
12 12 export default {
13 13 data () {
14 14 return {
15   - m1: 1
  15 + m1: 'yes'
16 16 }
17 17 },
18 18 methods: {
... ...
src/components/switch/switch.vue
1 1 <template>
2 2 <span :class="wrapClasses" @click="toggle">
3 3 <span :class="innerClasses">
4   - <slot name="open" v-if="currentValue"></slot>
5   - <slot name="close" v-if="!currentValue"></slot>
  4 + <slot name="open" v-if="currentValue === trueValue"></slot>
  5 + <slot name="close" v-if="currentValue === falseValue"></slot>
6 6 </span>
7 7 </span>
8 8 </template>
... ... @@ -48,7 +48,7 @@
48 48 return [
49 49 `${prefixCls}`,
50 50 {
51   - [`${prefixCls}-checked`]: this.currentValue,
  51 + [`${prefixCls}-checked`]: this.currentValue === this.trueValue,
52 52 [`${prefixCls}-disabled`]: this.disabled,
53 53 [`${prefixCls}-${this.size}`]: !!this.size
54 54 }
... ...