Commit d170399368fc20d0123d4fdc43498004cd6dd530

Authored by 梁灏
1 parent 3ad47566

update Slider

update Slider
Showing 2 changed files with 19 additions and 6 deletions   Show diff stats
src/components/slider/slider.vue
... ... @@ -291,6 +291,7 @@
291 291 if (!this.dragging) {
292 292 if (this.value !== this.oldSingleValue) {
293 293 this.$emit('on-change', this.value);
  294 + this.$dispatch('on-form-change', this.value);
294 295 this.oldSingleValue = this.value;
295 296 }
296 297 }
... ... @@ -303,6 +304,7 @@
303 304 this.value = val;
304 305 this.setSinglePosition(val);
305 306 this.$emit('on-change', this.value);
  307 + this.$dispatch('on-form-change', this.value);
306 308 },
307 309 // for range use first
308 310 onFirstButtonDown (event) {
... ... @@ -345,6 +347,7 @@
345 347 if (!this.firstDragging) {
346 348 if (this.value[0] !== this.oldFirstValue) {
347 349 this.$emit('on-change', this.value);
  350 + this.$dispatch('on-form-change', this.value);
348 351 this.oldFirstValue = this.value[0];
349 352 }
350 353 }
... ... @@ -394,6 +397,7 @@
394 397 if (!this.secondDragging) {
395 398 if (this.value[1] !== this.oldSecondValue) {
396 399 this.$emit('on-change', this.value);
  400 + this.$dispatch('on-form-change', this.value);
397 401 this.oldSecondValue = this.value[1];
398 402 }
399 403 }
... ...
test/routers/form.vue
... ... @@ -60,6 +60,9 @@
60 60 <i-option v-for="item in cityList" :value="item.value">{{ item.label }}</i-option>
61 61 </i-select>
62 62 </form-item>
  63 + <form-item label="多选滑块" prop="slider">
  64 + <Slider :value.sync="form.slider" range></Slider>
  65 + </form-item>
63 66 <form-item>
64 67 <i-button type="primary" @click="onSubmit('form')">提交</i-button>
65 68 </form-item>
... ... @@ -104,7 +107,8 @@
104 107 group: '',
105 108 checkboxgroup: [],
106 109 select: '',
107   - selectm: []
  110 + selectm: [],
  111 + slider: [40, 50]
108 112 },
109 113 rules: {
110 114 mail: [
... ... @@ -141,12 +145,17 @@
141 145 required: true
142 146 }
143 147 ],
144   - selectm: [
145   - {
146   - required: true, type: 'array'
147   - },
  148 + slider: [
148 149 {
149   - min: 2, type: 'array'
  150 + type: 'array', len: 2,
  151 + fields: {
  152 + 0: {
  153 + type: 'number', min: 30, 'message': '不能小于30'
  154 + },
  155 + 1: {
  156 + type: 'number', max: 90, 'message': '不能大于90'
  157 + }
  158 + }
150 159 }
151 160 ]
152 161 }
... ...