<template>
    <div class="list">
        <div class="item" :class="{active:activeId === index}" v-for="(item,index) in data" @click="itemClick(index,item.path)">
            <img :src="item.img">
            <span>{{item.title}}</span>
        </div>
    </div>
</template>

<script>
    export default{
        props:{
            data:{
                type:Array,
                default(){
                    return [];
                }
            },
            active:{
                type:Number,
                default:0
            }
        },
        data(){
            return {
                activeId:this.active
            }
        },
        methods:{
            itemClick(idx,path){
                this.activeId = idx;
//                this.$emit('click',path);
                this.$router.push(path);
            }
        }
    }
</script>

<style scoped>
    .list{
        border:1px solid #d6d6d6;
    }

    .item{
        font-size:0;
        padding:10px 20px;
        cursor:pointer;
        background-color:#f7f7f7;
    }

    .item:not(:last-child){
        border-bottom:1px solid #d6d6d6;
    }

    .item:hover{
        background-color:#fff;
    }

    .item.active{
        background-color:#fff;
    }

    .item img{
        width:16px;
    }

    .item span{
        font-size:14px;
        vertical-align: middle;
        margin-left:5px;
    }
</style>
