How to implement a Star Evaluation component in vue-star
This article focuses on "how to implement a star evaluation component in vue-star". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "how to implement a star evaluation component in vue-star"!
Create Star.vue under the star folder, and related picture information. Facilitate the nearby maintenance of components
Star.vue:
Const LENGTH = 5; const CLS_ON = 'on'; const CLS_HALF =' half'; const CLS_OFF = 'off'; export default {props: {size: {/ / size, 24authoring 36th type: Number}, score: {type: Number}}, computed: {starSize () {return' star-'+ this.size;}, itemClasses () {let result = []; let score = Math.floor (this.score*2) / 2 / / adjust the value to integer and .5, for example: 4.3 = > 4 4. 6 = > 4. 5 let hasDecimal = score% 1! = = 0; let integer = Math.floor (score); for (let I = 0