<template>
   <div class="stars">
        <div v-for="(item,ind) in num" :key="ind" 
        :class="{'on':ind<=cur}" 
        @mouseover='enter(ind)'
        @mouseleave="out()"
        @click="ok(ind)"></div>
   </div>
</template>
<script>
    export default{
    name:'Star',
    data(){
        return{
            num:5,
            cur:-1,
            flag:false
        }
    },
    methods:{
        enter(ind){
            if(!this.flag){
                this.cur=ind;
            }
        },
        out(){
            if(!this.flag){
                this.cur=-1;
            }
        },
        ok(ind){
           this.flag=true;
           this.cur=ind; 
        }
    }
    }
</script>
<style scoped>
    .stars div{
           width: 56px;
        height: 59px;
        background: url('../../static/img/off.png') no-repeat;
        float: left;
    }
    .stars .on{
        width: 56px;
        height: 59px;
        background: url('../../static/img/on.png') no-repeat;
    }
</style>

 

相关文章:

  • 2021-12-12
  • 2021-12-18
  • 2022-12-23
  • 2021-07-21
  • 2021-10-05
  • 2021-06-30
  • 2022-12-23
  • 2021-08-24
猜你喜欢
  • 2021-11-28
  • 2021-04-11
  • 2021-09-07
  • 2022-12-23
  • 2022-01-17
  • 2021-12-12
相关资源
相似解决方案