mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
chore: use gen instead of render (#4922)
This commit is contained in:
parent
9c54a77845
commit
56e9b7afa0
@ -30,7 +30,7 @@ export default createComponent({
|
||||
this.$refs.field.blur();
|
||||
},
|
||||
|
||||
renderFinish() {
|
||||
genFinish() {
|
||||
const show = this.value && this.focused && android;
|
||||
if (show) {
|
||||
return (
|
||||
@ -41,7 +41,7 @@ export default createComponent({
|
||||
}
|
||||
},
|
||||
|
||||
renderSearchResult() {
|
||||
genSearchResult() {
|
||||
const { searchResult } = this;
|
||||
const show = this.focused && searchResult && this.showSearchResult;
|
||||
if (show) {
|
||||
@ -75,10 +75,10 @@ export default createComponent({
|
||||
label={t('label')}
|
||||
maxlength={this.detailMaxlength}
|
||||
placeholder={t('placeholder')}
|
||||
scopedSlots={{ icon: this.renderFinish }}
|
||||
scopedSlots={{ icon: this.genFinish }}
|
||||
{...{ on: this.$listeners }}
|
||||
/>
|
||||
{this.renderSearchResult()}
|
||||
{this.genSearchResult()}
|
||||
</Cell>
|
||||
);
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ function AddressItem(
|
||||
emit(ctx, 'click');
|
||||
}
|
||||
|
||||
const renderRightIcon = () => (
|
||||
const genRightIcon = () => (
|
||||
<Icon
|
||||
name="edit"
|
||||
class={bem('edit')}
|
||||
@ -57,7 +57,7 @@ function AddressItem(
|
||||
/>
|
||||
);
|
||||
|
||||
const renderContent = () => {
|
||||
const genContent = () => {
|
||||
const { data } = props;
|
||||
const Info = [
|
||||
<div class={bem('name')}>{`${data.name},${data.tel}`}</div>,
|
||||
@ -79,8 +79,8 @@ function AddressItem(
|
||||
valueClass={bem('value')}
|
||||
clickable={switchable && !disabled}
|
||||
scopedSlots={{
|
||||
default: renderContent,
|
||||
'right-icon': renderRightIcon
|
||||
default: genContent,
|
||||
'right-icon': genRightIcon
|
||||
}}
|
||||
onClick={onClick}
|
||||
{...inherit(ctx)}
|
||||
|
@ -29,7 +29,7 @@ function AddressList(
|
||||
slots: AddressListSlots,
|
||||
ctx: RenderContext<AddressListProps>
|
||||
) {
|
||||
function renderList(list?: AddressItemData[], disabled?: boolean) {
|
||||
function genList(list?: AddressItemData[], disabled?: boolean) {
|
||||
if (!list) {
|
||||
return;
|
||||
}
|
||||
@ -57,8 +57,8 @@ function AddressList(
|
||||
));
|
||||
}
|
||||
|
||||
const List = renderList(props.list);
|
||||
const DisabledList = renderList(props.disabledList, true);
|
||||
const List = genList(props.list);
|
||||
const DisabledList = genList(props.disabledList, true);
|
||||
|
||||
return (
|
||||
<div class={bem()} {...inherit(ctx)}>
|
||||
|
@ -127,7 +127,7 @@ export default createComponent({
|
||||
});
|
||||
},
|
||||
|
||||
renderEmpty() {
|
||||
genEmpty() {
|
||||
return (
|
||||
<div class={bem('empty')}>
|
||||
<img src={this.emptyImage} />
|
||||
@ -136,7 +136,7 @@ export default createComponent({
|
||||
);
|
||||
},
|
||||
|
||||
renderExchangeButton() {
|
||||
genExchangeButton() {
|
||||
return (
|
||||
<Button
|
||||
size="small"
|
||||
@ -167,7 +167,7 @@ export default createComponent({
|
||||
placeholder={this.inputPlaceholder || t('placeholder')}
|
||||
maxlength="20"
|
||||
scopedSlots={{
|
||||
button: this.renderExchangeButton
|
||||
button: this.genExchangeButton
|
||||
}}
|
||||
/>
|
||||
);
|
||||
@ -187,7 +187,7 @@ export default createComponent({
|
||||
nativeOnClick={onChange(index)}
|
||||
/>
|
||||
))}
|
||||
{!coupons.length && this.renderEmpty()}
|
||||
{!coupons.length && this.genEmpty()}
|
||||
</div>
|
||||
</Tab>
|
||||
);
|
||||
@ -198,7 +198,7 @@ export default createComponent({
|
||||
{disabledCoupons.map(coupon => (
|
||||
<Coupon disabled key={coupon.id} coupon={coupon} currency={this.currency} />
|
||||
))}
|
||||
{!disabledCoupons.length && this.renderEmpty()}
|
||||
{!disabledCoupons.length && this.genEmpty()}
|
||||
</div>
|
||||
</Tab>
|
||||
);
|
||||
|
@ -202,7 +202,7 @@ export default createComponent({
|
||||
}
|
||||
},
|
||||
|
||||
renderInput() {
|
||||
genInput() {
|
||||
const inputSlot = this.slots('input');
|
||||
|
||||
if (inputSlot) {
|
||||
@ -240,7 +240,7 @@ export default createComponent({
|
||||
return <input type={this.type} {...inputProps} />;
|
||||
},
|
||||
|
||||
renderLeftIcon() {
|
||||
genLeftIcon() {
|
||||
const showLeftIcon = this.slots('left-icon') || this.leftIcon;
|
||||
if (showLeftIcon) {
|
||||
return (
|
||||
@ -251,7 +251,7 @@ export default createComponent({
|
||||
}
|
||||
},
|
||||
|
||||
renderRightIcon() {
|
||||
genRightIcon() {
|
||||
const { slots } = this;
|
||||
const showRightIcon = slots('right-icon') || this.rightIcon;
|
||||
if (showRightIcon) {
|
||||
@ -263,7 +263,7 @@ export default createComponent({
|
||||
}
|
||||
},
|
||||
|
||||
renderWordLimit() {
|
||||
genWordLimit() {
|
||||
if (this.showWordLimit && this.$attrs.maxlength) {
|
||||
return (
|
||||
<div class={bem('word-limit')}>
|
||||
@ -278,7 +278,7 @@ export default createComponent({
|
||||
const { slots, labelAlign } = this;
|
||||
|
||||
const scopedSlots = {
|
||||
icon: this.renderLeftIcon
|
||||
icon: this.genLeftIcon
|
||||
};
|
||||
if (slots('label')) {
|
||||
scopedSlots.title = () => slots('label');
|
||||
@ -306,14 +306,14 @@ export default createComponent({
|
||||
onClick={this.onClick}
|
||||
>
|
||||
<div class={bem('body')}>
|
||||
{this.renderInput()}
|
||||
{this.genInput()}
|
||||
{this.showClear && (
|
||||
<Icon name="clear" class={bem('clear')} onTouchstart={this.onClear} />
|
||||
)}
|
||||
{this.renderRightIcon()}
|
||||
{this.genRightIcon()}
|
||||
{slots('button') && <div class={bem('button')}>{slots('button')}</div>}
|
||||
</div>
|
||||
{this.renderWordLimit()}
|
||||
{this.genWordLimit()}
|
||||
{this.errorMessage && (
|
||||
<div class={bem('error-message', this.errorMessageAlign)}>
|
||||
{this.errorMessage}
|
||||
|
@ -104,7 +104,7 @@ export default createComponent({
|
||||
this.$emit('click', event);
|
||||
},
|
||||
|
||||
renderPlaceholder() {
|
||||
genPlaceholder() {
|
||||
if (this.loading && this.showLoading) {
|
||||
return (
|
||||
<div class={bem('loading')}>
|
||||
@ -122,7 +122,7 @@ export default createComponent({
|
||||
}
|
||||
},
|
||||
|
||||
renderImage() {
|
||||
genImage() {
|
||||
const imgData = {
|
||||
class: bem('img'),
|
||||
attrs: {
|
||||
@ -150,8 +150,8 @@ export default createComponent({
|
||||
render() {
|
||||
return (
|
||||
<div class={bem({ round: this.round })} style={this.style} onClick={this.onClick}>
|
||||
{this.renderImage()}
|
||||
{this.renderPlaceholder()}
|
||||
{this.genImage()}
|
||||
{this.genPlaceholder()}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ export default createComponent({
|
||||
return this.allowHalf ? 0.5 : 1;
|
||||
},
|
||||
|
||||
renderStar(status, index) {
|
||||
genStar(status, index) {
|
||||
const { icon, color, count, voidIcon, disabled, voidColor, disabledColor } = this;
|
||||
const score = index + 1;
|
||||
const isFull = status === 'full';
|
||||
@ -196,7 +196,7 @@ export default createComponent({
|
||||
onTouchstart={this.onTouchStart}
|
||||
onTouchmove={this.onTouchMove}
|
||||
>
|
||||
{this.list.map((status, index) => this.renderStar(status, index))}
|
||||
{this.list.map((status, index) => this.genStar(status, index))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ export default createComponent({
|
||||
this.$toast(t('oversize', this.maxSize));
|
||||
},
|
||||
|
||||
renderUploader(content, disabled = false) {
|
||||
genUploader(content, disabled = false) {
|
||||
return (
|
||||
<Uploader
|
||||
class={bem('uploader')}
|
||||
@ -60,7 +60,7 @@ export default createComponent({
|
||||
);
|
||||
},
|
||||
|
||||
renderMask() {
|
||||
genMask() {
|
||||
return (
|
||||
<div class={bem('mask')}>
|
||||
{this.uploadFail
|
||||
@ -80,7 +80,7 @@ export default createComponent({
|
||||
render() {
|
||||
return (
|
||||
<div class={bem()}>
|
||||
{this.value && this.renderUploader(
|
||||
{this.value && this.genUploader(
|
||||
[
|
||||
<img src={this.value} />,
|
||||
<Icon
|
||||
@ -94,15 +94,15 @@ export default createComponent({
|
||||
true
|
||||
)}
|
||||
|
||||
{this.paddingImg && this.renderUploader(
|
||||
{this.paddingImg && this.genUploader(
|
||||
[
|
||||
<img src={this.paddingImg} />,
|
||||
this.renderMask()
|
||||
this.genMask()
|
||||
],
|
||||
!this.uploadFail
|
||||
)}
|
||||
|
||||
{!this.value && !this.paddingImg && this.renderUploader(
|
||||
{!this.value && !this.paddingImg && this.genUploader(
|
||||
<div class={bem('trigger')}>
|
||||
<Icon name="photograph" size="22px" />
|
||||
</div>
|
||||
|
@ -312,7 +312,7 @@ export default createComponent({
|
||||
}
|
||||
},
|
||||
|
||||
renderIndicator() {
|
||||
genIndicator() {
|
||||
const { count, activeIndicator } = this;
|
||||
const slot = this.slots('indicator');
|
||||
|
||||
@ -349,7 +349,7 @@ export default createComponent({
|
||||
>
|
||||
{this.slots()}
|
||||
</div>
|
||||
{this.renderIndicator()}
|
||||
{this.genIndicator()}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ export default createComponent({
|
||||
}
|
||||
},
|
||||
|
||||
renderChildren() {
|
||||
genChildren() {
|
||||
if (this.animated) {
|
||||
return (
|
||||
<div class={bem('track')} style={this.style}>
|
||||
@ -72,7 +72,7 @@ export default createComponent({
|
||||
class={bem('content', { animated: this.animated })}
|
||||
{...{ on: this.listeners }}
|
||||
>
|
||||
{this.renderChildren()}
|
||||
{this.genChildren()}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ export default createComponent({
|
||||
}
|
||||
},
|
||||
|
||||
renderPreviewItem(item, index) {
|
||||
genPreviewItem(item, index) {
|
||||
const DeleteIcon = (
|
||||
<Icon
|
||||
name="clear"
|
||||
@ -265,13 +265,13 @@ export default createComponent({
|
||||
);
|
||||
},
|
||||
|
||||
renderPreviewList() {
|
||||
genPreviewList() {
|
||||
if (this.previewImage) {
|
||||
return this.fileList.map(this.renderPreviewItem);
|
||||
return this.fileList.map(this.genPreviewItem);
|
||||
}
|
||||
},
|
||||
|
||||
renderUpload() {
|
||||
genUpload() {
|
||||
if (this.fileList.length >= this.maxCount) {
|
||||
return;
|
||||
}
|
||||
@ -322,8 +322,8 @@ export default createComponent({
|
||||
return (
|
||||
<div class={bem()}>
|
||||
<div class={bem('wrapper')}>
|
||||
{this.renderPreviewList()}
|
||||
{this.renderUpload()}
|
||||
{this.genPreviewList()}
|
||||
{this.genUpload()}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user