mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
* [bugfix] CouponList always show empty info * [bugfix] add click feedback of buttons in components * [Doc] add custom theme document * [new feature] Notice bar support more props * [bugfix] PullRefresh test cases * [bugfix] unused NoticeBar style * [bugfix] Swipe width calc error * [Doc] english document of all action components * [Doc] change document site path to /zanui/vant * [Doc] fix * [bugfix] uploader style error * [bugfix] tabs document demo * [new feature] Cell support vue-router target route * [bugfix] add cell test cases * update yarn.lock
67 lines
1.5 KiB
Vue
67 lines
1.5 KiB
Vue
<template>
|
|
<div :class="['van-cell', 'van-hairline', { 'van-cell--required': required }]" @click="onClick">
|
|
<div class="van-cell__title" v-if="$slots.title || title">
|
|
<slot name="icon">
|
|
<van-icon v-if="icon" :name="icon" />
|
|
</slot>
|
|
<slot name="title">
|
|
<span class="van-cell__text" v-text="title" />
|
|
<span class="van-cell__label" v-if="label" v-text="label" />
|
|
</slot>
|
|
</div>
|
|
<div
|
|
class="van-cell__value"
|
|
v-if="value || $slots.default"
|
|
:class="{
|
|
'van-cell__value--link': isLink,
|
|
'van-cell__value--alone': !$slots.title && !title && !label
|
|
}"
|
|
>
|
|
<slot>
|
|
<span v-text="value" />
|
|
</slot>
|
|
</div>
|
|
<slot name="right-icon">
|
|
<van-icon name="arrow" class="van-cell__right-icon" v-if="isLink" />
|
|
</slot>
|
|
<slot name="extra" />
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import Icon from '../icon';
|
|
|
|
export default {
|
|
name: 'van-cell',
|
|
|
|
components: {
|
|
[Icon.name]: Icon
|
|
},
|
|
|
|
props: {
|
|
url: String,
|
|
icon: String,
|
|
title: String,
|
|
label: String,
|
|
isLink: Boolean,
|
|
replace: Boolean,
|
|
required: Boolean,
|
|
to: [String, Object],
|
|
value: [String, Number]
|
|
},
|
|
|
|
methods: {
|
|
onClick() {
|
|
this.$emit('click');
|
|
|
|
const { to, url, $router, replace } = this;
|
|
if (to && $router) {
|
|
$router[replace ? 'replace' : 'push'](to);
|
|
} else if (url) {
|
|
replace ? location.replace(url) : location.href = url;
|
|
}
|
|
}
|
|
}
|
|
};
|
|
</script>
|