码迷,mamicode.com
首页 > 其他好文 > 详细

vue组件star开发基于vue-cli

时间:2018-07-27 22:28:20      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:temp   turn   div   return   mouse   tar   stars   vue   idt   

<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>

 

vue组件star开发基于vue-cli

标签:temp   turn   div   return   mouse   tar   stars   vue   idt   

原文地址:https://www.cnblogs.com/l8l8/p/9379809.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!