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,6 +291,7 @@
291 if (!this.dragging) { 291 if (!this.dragging) {
292 if (this.value !== this.oldSingleValue) { 292 if (this.value !== this.oldSingleValue) {
293 this.$emit('on-change', this.value); 293 this.$emit('on-change', this.value);
  294 + this.$dispatch('on-form-change', this.value);
294 this.oldSingleValue = this.value; 295 this.oldSingleValue = this.value;
295 } 296 }
296 } 297 }
@@ -303,6 +304,7 @@ @@ -303,6 +304,7 @@
303 this.value = val; 304 this.value = val;
304 this.setSinglePosition(val); 305 this.setSinglePosition(val);
305 this.$emit('on-change', this.value); 306 this.$emit('on-change', this.value);
  307 + this.$dispatch('on-form-change', this.value);
306 }, 308 },
307 // for range use first 309 // for range use first
308 onFirstButtonDown (event) { 310 onFirstButtonDown (event) {
@@ -345,6 +347,7 @@ @@ -345,6 +347,7 @@
345 if (!this.firstDragging) { 347 if (!this.firstDragging) {
346 if (this.value[0] !== this.oldFirstValue) { 348 if (this.value[0] !== this.oldFirstValue) {
347 this.$emit('on-change', this.value); 349 this.$emit('on-change', this.value);
  350 + this.$dispatch('on-form-change', this.value);
348 this.oldFirstValue = this.value[0]; 351 this.oldFirstValue = this.value[0];
349 } 352 }
350 } 353 }
@@ -394,6 +397,7 @@ @@ -394,6 +397,7 @@
394 if (!this.secondDragging) { 397 if (!this.secondDragging) {
395 if (this.value[1] !== this.oldSecondValue) { 398 if (this.value[1] !== this.oldSecondValue) {
396 this.$emit('on-change', this.value); 399 this.$emit('on-change', this.value);
  400 + this.$dispatch('on-form-change', this.value);
397 this.oldSecondValue = this.value[1]; 401 this.oldSecondValue = this.value[1];
398 } 402 }
399 } 403 }
test/routers/form.vue
@@ -60,6 +60,9 @@ @@ -60,6 +60,9 @@
60 <i-option v-for="item in cityList" :value="item.value">{{ item.label }}</i-option> 60 <i-option v-for="item in cityList" :value="item.value">{{ item.label }}</i-option>
61 </i-select> 61 </i-select>
62 </form-item> 62 </form-item>
  63 + <form-item label="多选滑块" prop="slider">
  64 + <Slider :value.sync="form.slider" range></Slider>
  65 + </form-item>
63 <form-item> 66 <form-item>
64 <i-button type="primary" @click="onSubmit('form')">提交</i-button> 67 <i-button type="primary" @click="onSubmit('form')">提交</i-button>
65 </form-item> 68 </form-item>
@@ -104,7 +107,8 @@ @@ -104,7 +107,8 @@
104 group: '', 107 group: '',
105 checkboxgroup: [], 108 checkboxgroup: [],
106 select: '', 109 select: '',
107 - selectm: [] 110 + selectm: [],
  111 + slider: [40, 50]
108 }, 112 },
109 rules: { 113 rules: {
110 mail: [ 114 mail: [
@@ -141,12 +145,17 @@ @@ -141,12 +145,17 @@
141 required: true 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 }