Commit 2eccfc99381f3f5bbbf510edac1e08de4b1bf8fa
1 parent
feb21a0a
fixed #2852
Showing
3 changed files
with
74 additions
and
29 deletions
Show diff stats
examples/routers/slider.vue
1 | -<template> | ||
2 | - <div style="margin: 0 400px;"> | ||
3 | - <Slider v-model="valueSingle" @on-change="updateSingleDisplayValue"></Slider> | ||
4 | - <Button @click="randomSingle">change</Button> {{singleDisplayValue}} | 1 | +<!--<template>--> |
2 | + <!--<div style="margin: 0 400px;">--> | ||
3 | + <!--<Slider v-model="valueSingle" @on-change="updateSingleDisplayValue"></Slider>--> | ||
4 | + <!--<Button @click="randomSingle">change</Button> {{singleDisplayValue}}--> | ||
5 | + | ||
6 | + <!--<Slider v-model="valueRange" range @on-change="updateRangeDisplayValue"></Slider>--> | ||
7 | + <!--<Button @click="randomRange">change</Button> {{rangeDisplayValue}}--> | ||
8 | + <!--</div>--> | ||
9 | +<!--</template>--> | ||
10 | +<!--<script>--> | ||
11 | + <!--export default {--> | ||
12 | + <!--data () {--> | ||
13 | + <!--return {--> | ||
14 | + <!--valueSingle: 10,--> | ||
15 | + <!--valueRange: [20, 50],--> | ||
16 | + <!--singleDisplayValue: 10,--> | ||
17 | + <!--rangeDisplayValue: [20, 50]--> | ||
18 | + <!--};--> | ||
19 | + <!--},--> | ||
20 | + <!--methods: {--> | ||
21 | + <!--updateSingleDisplayValue (val){--> | ||
22 | + <!--console.log('updateSingleDisplayValue', val);--> | ||
23 | + <!--this.singleDisplayValue = val;--> | ||
24 | + <!--},--> | ||
25 | + <!--updateRangeDisplayValue (val){--> | ||
26 | + <!--console.log('updateRangeDisplayValue', val);--> | ||
27 | + <!--this.rangeDisplayValue = val.join(' - ');--> | ||
28 | + <!--},--> | ||
29 | + <!--randomSingle () {--> | ||
30 | + <!--this.valueSingle = this.random(0, 100);--> | ||
31 | + <!--},--> | ||
32 | + <!--randomRange () {--> | ||
33 | + <!--this.valueRange = [this.random(0, 50), this.random(50, 100)];--> | ||
34 | + <!--},--> | ||
35 | + <!--random (min, max){--> | ||
36 | + <!--return Math.round(Math.random() * (max - min)) + min;--> | ||
37 | + <!--}--> | ||
38 | + <!--}--> | ||
39 | + <!--};--> | ||
40 | +<!--</script>--> | ||
5 | 41 | ||
6 | - <Slider v-model="valueRange" range @on-change="updateRangeDisplayValue"></Slider> | ||
7 | - <Button @click="randomRange">change</Button> {{rangeDisplayValue}} | 42 | + |
43 | +<template> | ||
44 | + <div> | ||
45 | + <Button type="primary" @click="modal1 = true">Display dialog box</Button> | ||
46 | + <Modal v-model="modal1"> | ||
47 | + <Slider v-model="value2" range show-tip="always"></Slider> | ||
48 | + </Modal> | ||
8 | </div> | 49 | </div> |
9 | </template> | 50 | </template> |
10 | <script> | 51 | <script> |
11 | export default { | 52 | export default { |
12 | data () { | 53 | data () { |
13 | return { | 54 | return { |
14 | - valueSingle: 10, | ||
15 | - valueRange: [20, 50], | ||
16 | - singleDisplayValue: 10, | ||
17 | - rangeDisplayValue: [20, 50] | ||
18 | - }; | 55 | + modal1: false, |
56 | + value2: [20, 50], | ||
57 | + } | ||
19 | }, | 58 | }, |
20 | methods: { | 59 | methods: { |
21 | - updateSingleDisplayValue (val){ | ||
22 | - console.log('updateSingleDisplayValue', val); | ||
23 | - this.singleDisplayValue = val; | ||
24 | - }, | ||
25 | - updateRangeDisplayValue (val){ | ||
26 | - console.log('updateRangeDisplayValue', val); | ||
27 | - this.rangeDisplayValue = val.join(' - '); | ||
28 | - }, | ||
29 | - randomSingle () { | ||
30 | - this.valueSingle = this.random(0, 100); | ||
31 | - }, | ||
32 | - randomRange () { | ||
33 | - this.valueRange = [this.random(0, 50), this.random(50, 100)]; | 60 | + ok () { |
61 | + this.$Message.info('Clicked ok'); | ||
34 | }, | 62 | }, |
35 | - random (min, max){ | ||
36 | - return Math.round(Math.random() * (max - min)) + min; | 63 | + cancel () { |
64 | + this.$Message.info('Clicked cancel'); | ||
37 | } | 65 | } |
38 | } | 66 | } |
39 | - }; | 67 | + } |
40 | </script> | 68 | </script> |
src/components/modal/modal.vue
@@ -229,6 +229,7 @@ | @@ -229,6 +229,7 @@ | ||
229 | } | 229 | } |
230 | } | 230 | } |
231 | this.broadcast('Table', 'on-visible-change', val); | 231 | this.broadcast('Table', 'on-visible-change', val); |
232 | + this.broadcast('Slider', 'on-visible-change', val); // #2852 | ||
232 | this.$emit('on-visible-change', val); | 233 | this.$emit('on-visible-change', val); |
233 | }, | 234 | }, |
234 | loading (val) { | 235 | loading (val) { |
src/components/slider/slider.vue
@@ -272,8 +272,7 @@ | @@ -272,8 +272,7 @@ | ||
272 | } | 272 | } |
273 | }, | 273 | }, |
274 | 274 | ||
275 | - | ||
276 | - sliderClick: function (event) { | 275 | + sliderClick (event) { |
277 | if (this.disabled) return; | 276 | if (this.disabled) return; |
278 | const currentX = this.getPointerX(event); | 277 | const currentX = this.getPointerX(event); |
279 | const sliderOffsetLeft = this.$refs.slider.getBoundingClientRect().left; | 278 | const sliderOffsetLeft = this.$refs.slider.getBoundingClientRect().left; |
@@ -290,6 +289,23 @@ | @@ -290,6 +289,23 @@ | ||
290 | this.$emit('on-change', exportValue); | 289 | this.$emit('on-change', exportValue); |
291 | this.dispatch('FormItem', 'on-form-change', exportValue); | 290 | this.dispatch('FormItem', 'on-form-change', exportValue); |
292 | }, | 291 | }, |
292 | + }, | ||
293 | + mounted () { | ||
294 | + // #2852 | ||
295 | + this.$on('on-visible-change', (val) => { | ||
296 | + if (val && this.showTip === 'always') { | ||
297 | + this.$refs.minTooltip.doDestroy(); | ||
298 | + if (this.range) { | ||
299 | + this.$refs.maxTooltip.doDestroy(); | ||
300 | + } | ||
301 | + this.$nextTick(() => { | ||
302 | + this.$refs.minTooltip.updatePopper(); | ||
303 | + if (this.range) { | ||
304 | + this.$refs.maxTooltip.updatePopper(); | ||
305 | + } | ||
306 | + }); | ||
307 | + } | ||
308 | + }); | ||
293 | } | 309 | } |
294 | }; | 310 | }; |
295 | </script> | 311 | </script> |