/
RatingDemo_4.vue
61 lines (60 loc) · 1.62 KB
/
RatingDemo_4.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<template>
<div class="lv-demo_layout">
<div>
<p>On mouse click</p>
<lv-rating :star-size="40" :show-rating="true" @update:rating="rating = $event"></lv-rating>
<div style="margin-top: 10px; font-weight: bold">
{{ currentRatingText }}
</div>
</div>
<div style="width: 40%">
<p>On mouse hover</p>
<div @mouseleave="mouseOverRating = null" style="display: inline-block">
<lv-rating :star-size="40" :show-rating="true" @hover:rating="mouseOverRating = $event" :increment="0.5"></lv-rating>
</div>
<div style="margin-top: 10px; font-weight: bold">
{{ mouseOverRatingText }}
</div>
</div>
</div>
</template>
<script>
import LvRating from 'lightvue/rating';
export default {
components: {
LvRating,
},
methods: {
showCurrentRating(rating) {
this.currentSelectedRating = rating === 0 ? this.currentSelectedRating : 'Click to select ' + rating + ' stars';
},
setCurrentSelectedRating(rating) {
this.currentSelectedRating = 'You have Selected: ' + rating + ' stars';
},
},
computed: {
currentRatingText() {
return this.rating ? 'You have selected ' + this.rating + ' stars' : 'No rating selected';
},
mouseOverRatingText() {
return this.mouseOverRating ? 'Click to select ' + this.mouseOverRating + ' stars' : 'No Rating';
},
},
data() {
return {
rating: null,
resetableRating: 2,
currentRating: 'No Rating',
mouseOverRating: null,
};
},
};
</script>
<style>
.lv-demo_layout {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 1rem;
}
</style>