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 | 49 | </div> |
9 | 50 | </template> |
10 | 51 | <script> |
11 | 52 | export default { |
12 | 53 | data () { |
13 | 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 | 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 | 68 | </script> | ... | ... |
src/components/modal/modal.vue
src/components/slider/slider.vue
... | ... | @@ -272,8 +272,7 @@ |
272 | 272 | } |
273 | 273 | }, |
274 | 274 | |
275 | - | |
276 | - sliderClick: function (event) { | |
275 | + sliderClick (event) { | |
277 | 276 | if (this.disabled) return; |
278 | 277 | const currentX = this.getPointerX(event); |
279 | 278 | const sliderOffsetLeft = this.$refs.slider.getBoundingClientRect().left; |
... | ... | @@ -290,6 +289,23 @@ |
290 | 289 | this.$emit('on-change', exportValue); |
291 | 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 | 311 | </script> | ... | ... |