[improvement] Cell: optimize performance (#1050)

This commit is contained in:
neverland 2018-12-11 15:11:28 +08:00 committed by GitHub
parent 8fc9ce3b9c
commit 15576ab95a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 20 deletions

View File

@ -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);

View File

@ -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 }}">

View File

@ -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)) {