This commit is contained in:
zhuxiang
2017-02-28 17:41:30 +08:00
parent 04712433c0
commit ba405b723b
4 changed files with 68 additions and 10 deletions
+6 -1
View File
@@ -6,6 +6,11 @@
<script>
export default {
name: 'z-badge-group'
name: 'z-badge-group',
data () {
return {
activeKey: '0'
}
}
};
</script>
+24 -5
View File
@@ -1,22 +1,41 @@
<template>
<a class="z-badge" :class="{ 'is-select' : isSelected }" :href="url" @click="handleClick">
<a class="z-badge" :class="classNames" :href="url" @click="handleClick">
<div class="z-badge__active"></div>
<div v-if="info" class="z-badge__info">{{info}}</div>
{{value}}
{{title}}
</a>
</template>
<script>
export default {
name: 'z-badge',
props: {
badgeKey: {
type: [Number, String],
required: true
},
title: {
type: String,
required: true
},
url: String,
value: String,
info: String,
isSelected: Boolean
info: String
},
data () {
return {
isSelected: false
}
},
methods: {
handleClick() {
this.$emit('click');
this.$parent.activeKey = this.badgeKey;
}
},
computed: {
classNames () {
return {
'is-select': this.badgeKey == this.$parent.activeKey ? true : false
}
}
}
};