Reputation: 7145
My use case is something like this,
This is my code.
<template>
<div id="app">
<span class="demo">★★★★★</span>
</div>
</template>
<script>
export default {
name: 'app',
data () {
return {
}
},
methods:{
}
}
</script>
<style>
.demo{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
font-size: 6em;
color:yellow;
text-shadow: 0 0 15px blue;
}
</style>
Upvotes: 2
Views: 327
Reputation: 135742
You could use v-for
and some CSS classes, as shown below.
They would iterate starRank
times creating filled-star
stars and then iterate 5 - starRank
times creating not-filled-star
stars.
In the example below, starRank
is 3
and, as such, three stars will be yellow.
new Vue({
el: '#app',
data() {
return {
starRank: 3
}
}
})
.demo {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 6em;
text-shadow: 0 0 15px blue;
}
.filled-star { color: yellow; }
.not-filled-star { color: blue; }
<script src="https://unpkg.com/vue"></script>
<div id="app">
<span class="demo">
<span v-for="index in starRank" class="filled-star">★</span><span v-for="index in (5-starRank)" class="not-filled-star">★</span>
</span>
</div>
Upvotes: 2