1๐
โ
fa-${i <= level ? 'solid' : 'regular'}
help you :
<template>
<div id="five-stars">
<font-awesome-icon v-for="i in 5" :key="i" :icon="`fa-${i <= level ? 'solid' : 'regular'} fa-star`" size="6x"/>
</div>
</template>
<script>
export default {
name: "ThreeScene",
data() {
return {
level: 1
};
}
}
</script>
๐คWahyu Kristianto
0๐
Use a v-for loop
<template>
<div id="five-stars">
<font-awesome-icon
v-for="level in 5"
:key="level"
:icon="`${level} fa-star"
size="6x"
/>
</div>
</template>
<script setup>
import { ref } from 'vue'
const data = ref([
'fa-solid',
'fa-regular',
'fa-solid',
'fa-regular',
'fa-solid'
])
</script>
note that the variable level
will start with the value of 1
, not 0
.
๐คRemicaster
Source:stackexchange.com