mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
41 lines
664 B
Vue
41 lines
664 B
Vue
<template>
|
|
<a
|
|
:class="[b({ select }), 'van-hairline']"
|
|
:href="url"
|
|
@click="onClick"
|
|
>
|
|
<div v-if="isDef(info)" :class="b('info')">{{ info }}</div>
|
|
{{ title }}
|
|
</a>
|
|
</template>
|
|
|
|
<script>
|
|
import create from '../utils/create';
|
|
|
|
export default create({
|
|
name: 'badge',
|
|
|
|
props: {
|
|
url: String,
|
|
info: [String, Number],
|
|
title: String
|
|
},
|
|
|
|
beforeCreate() {
|
|
this.$parent.badges.push(this);
|
|
},
|
|
|
|
computed: {
|
|
select() {
|
|
return this.$parent.badges.indexOf(this) === this.$parent.activeKey;
|
|
}
|
|
},
|
|
|
|
methods: {
|
|
onClick() {
|
|
this.$emit('click', this.$parent.badges.indexOf(this));
|
|
}
|
|
}
|
|
});
|
|
</script>
|