mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-05-22 06:31:46 +08:00
[improvement] Cell: optimize performance (#1050)
This commit is contained in:
parent
8fc9ce3b9c
commit
15576ab95a
@ -30,24 +30,6 @@ VantComponent({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
|
||||||
cellClass(): string {
|
|
||||||
const { data } = this;
|
|
||||||
return this.classNames('van-cell', {
|
|
||||||
'van-cell--center': data.center,
|
|
||||||
'van-cell--required': data.required,
|
|
||||||
'van-cell--borderless': !data.border,
|
|
||||||
'van-cell--clickable': data.isLink || data.clickable,
|
|
||||||
[`van-cell--${data.size}`]: data.size
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
titleStyle(): string {
|
|
||||||
const { titleWidth } = this.data;
|
|
||||||
return titleWidth ? `max-width: ${titleWidth};min-width: ${titleWidth}` : '';
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
onClick(event: Weapp.Event) {
|
onClick(event: Weapp.Event) {
|
||||||
this.$emit('click', event.detail);
|
this.$emit('click', event.detail);
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
|
<wxs src="../wxs/utils.wxs" module="utils" />
|
||||||
|
|
||||||
<view
|
<view
|
||||||
class="custom-class {{ cellClass }}"
|
class="custom-class {{ utils.bem('cell', [size, { center, required, borderless: !border, clickable: isLink || clickable }]) }}"
|
||||||
style="{{ customStyle }}"
|
style="{{ customStyle }}"
|
||||||
bind:tap="onClick"
|
bind:tap="onClick"
|
||||||
>
|
>
|
||||||
@ -12,7 +14,7 @@
|
|||||||
<slot wx:else name="icon" />
|
<slot wx:else name="icon" />
|
||||||
|
|
||||||
<view
|
<view
|
||||||
style="{{ titleStyle }}"
|
style="{{ titleWidth ? 'max-width:' + titleWidth + ';min-width:' + titleWidth : '' }}"
|
||||||
class="van-cell__title title-class"
|
class="van-cell__title title-class"
|
||||||
>
|
>
|
||||||
<block wx:if="{{ title }}">
|
<block wx:if="{{ title }}">
|
||||||
|
@ -12,6 +12,10 @@ function join(name, mods) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function traversing(mods, conf) {
|
function traversing(mods, conf) {
|
||||||
|
if (!conf) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof conf === 'string') {
|
if (typeof conf === 'string') {
|
||||||
mods.push(conf);
|
mods.push(conf);
|
||||||
} else if (array.isArray(conf)) {
|
} else if (array.isArray(conf)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user