Skip to content

Commit 56e9b7a

Browse files
authored
chore: use gen instead of render (youzan#4922)
1 parent 9c54a77 commit 56e9b7a

File tree

11 files changed

+46
-46
lines changed

11 files changed

+46
-46
lines changed

src/address-edit/Detail.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default createComponent({
3030
this.$refs.field.blur();
3131
},
3232

33-
renderFinish() {
33+
genFinish() {
3434
const show = this.value && this.focused && android;
3535
if (show) {
3636
return (
@@ -41,7 +41,7 @@ export default createComponent({
4141
}
4242
},
4343

44-
renderSearchResult() {
44+
genSearchResult() {
4545
const { searchResult } = this;
4646
const show = this.focused && searchResult && this.showSearchResult;
4747
if (show) {
@@ -75,10 +75,10 @@ export default createComponent({
7575
label={t('label')}
7676
maxlength={this.detailMaxlength}
7777
placeholder={t('placeholder')}
78-
scopedSlots={{ icon: this.renderFinish }}
78+
scopedSlots={{ icon: this.genFinish }}
7979
{...{ on: this.$listeners }}
8080
/>
81-
{this.renderSearchResult()}
81+
{this.genSearchResult()}
8282
</Cell>
8383
);
8484
}

src/address-list/Item.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function AddressItem(
4545
emit(ctx, 'click');
4646
}
4747

48-
const renderRightIcon = () => (
48+
const genRightIcon = () => (
4949
<Icon
5050
name="edit"
5151
class={bem('edit')}
@@ -57,7 +57,7 @@ function AddressItem(
5757
/>
5858
);
5959

60-
const renderContent = () => {
60+
const genContent = () => {
6161
const { data } = props;
6262
const Info = [
6363
<div class={bem('name')}>{`${data.name}${data.tel}`}</div>,
@@ -79,8 +79,8 @@ function AddressItem(
7979
valueClass={bem('value')}
8080
clickable={switchable && !disabled}
8181
scopedSlots={{
82-
default: renderContent,
83-
'right-icon': renderRightIcon
82+
default: genContent,
83+
'right-icon': genRightIcon
8484
}}
8585
onClick={onClick}
8686
{...inherit(ctx)}

src/address-list/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function AddressList(
2929
slots: AddressListSlots,
3030
ctx: RenderContext<AddressListProps>
3131
) {
32-
function renderList(list?: AddressItemData[], disabled?: boolean) {
32+
function genList(list?: AddressItemData[], disabled?: boolean) {
3333
if (!list) {
3434
return;
3535
}
@@ -57,8 +57,8 @@ function AddressList(
5757
));
5858
}
5959

60-
const List = renderList(props.list);
61-
const DisabledList = renderList(props.disabledList, true);
60+
const List = genList(props.list);
61+
const DisabledList = genList(props.disabledList, true);
6262

6363
return (
6464
<div class={bem()} {...inherit(ctx)}>

src/coupon-list/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export default createComponent({
127127
});
128128
},
129129

130-
renderEmpty() {
130+
genEmpty() {
131131
return (
132132
<div class={bem('empty')}>
133133
<img src={this.emptyImage} />
@@ -136,7 +136,7 @@ export default createComponent({
136136
);
137137
},
138138

139-
renderExchangeButton() {
139+
genExchangeButton() {
140140
return (
141141
<Button
142142
size="small"
@@ -167,7 +167,7 @@ export default createComponent({
167167
placeholder={this.inputPlaceholder || t('placeholder')}
168168
maxlength="20"
169169
scopedSlots={{
170-
button: this.renderExchangeButton
170+
button: this.genExchangeButton
171171
}}
172172
/>
173173
);
@@ -187,7 +187,7 @@ export default createComponent({
187187
nativeOnClick={onChange(index)}
188188
/>
189189
))}
190-
{!coupons.length && this.renderEmpty()}
190+
{!coupons.length && this.genEmpty()}
191191
</div>
192192
</Tab>
193193
);
@@ -198,7 +198,7 @@ export default createComponent({
198198
{disabledCoupons.map(coupon => (
199199
<Coupon disabled key={coupon.id} coupon={coupon} currency={this.currency} />
200200
))}
201-
{!disabledCoupons.length && this.renderEmpty()}
201+
{!disabledCoupons.length && this.genEmpty()}
202202
</div>
203203
</Tab>
204204
);

src/field/index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ export default createComponent({
202202
}
203203
},
204204

205-
renderInput() {
205+
genInput() {
206206
const inputSlot = this.slots('input');
207207

208208
if (inputSlot) {
@@ -240,7 +240,7 @@ export default createComponent({
240240
return <input type={this.type} {...inputProps} />;
241241
},
242242

243-
renderLeftIcon() {
243+
genLeftIcon() {
244244
const showLeftIcon = this.slots('left-icon') || this.leftIcon;
245245
if (showLeftIcon) {
246246
return (
@@ -251,7 +251,7 @@ export default createComponent({
251251
}
252252
},
253253

254-
renderRightIcon() {
254+
genRightIcon() {
255255
const { slots } = this;
256256
const showRightIcon = slots('right-icon') || this.rightIcon;
257257
if (showRightIcon) {
@@ -263,7 +263,7 @@ export default createComponent({
263263
}
264264
},
265265

266-
renderWordLimit() {
266+
genWordLimit() {
267267
if (this.showWordLimit && this.$attrs.maxlength) {
268268
return (
269269
<div class={bem('word-limit')}>
@@ -278,7 +278,7 @@ export default createComponent({
278278
const { slots, labelAlign } = this;
279279

280280
const scopedSlots = {
281-
icon: this.renderLeftIcon
281+
icon: this.genLeftIcon
282282
};
283283
if (slots('label')) {
284284
scopedSlots.title = () => slots('label');
@@ -306,14 +306,14 @@ export default createComponent({
306306
onClick={this.onClick}
307307
>
308308
<div class={bem('body')}>
309-
{this.renderInput()}
309+
{this.genInput()}
310310
{this.showClear && (
311311
<Icon name="clear" class={bem('clear')} onTouchstart={this.onClear} />
312312
)}
313-
{this.renderRightIcon()}
313+
{this.genRightIcon()}
314314
{slots('button') && <div class={bem('button')}>{slots('button')}</div>}
315315
</div>
316-
{this.renderWordLimit()}
316+
{this.genWordLimit()}
317317
{this.errorMessage && (
318318
<div class={bem('error-message', this.errorMessageAlign)}>
319319
{this.errorMessage}

src/image/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export default createComponent({
104104
this.$emit('click', event);
105105
},
106106

107-
renderPlaceholder() {
107+
genPlaceholder() {
108108
if (this.loading && this.showLoading) {
109109
return (
110110
<div class={bem('loading')}>
@@ -122,7 +122,7 @@ export default createComponent({
122122
}
123123
},
124124

125-
renderImage() {
125+
genImage() {
126126
const imgData = {
127127
class: bem('img'),
128128
attrs: {
@@ -150,8 +150,8 @@ export default createComponent({
150150
render() {
151151
return (
152152
<div class={bem({ round: this.round })} style={this.style} onClick={this.onClick}>
153-
{this.renderImage()}
154-
{this.renderPlaceholder()}
153+
{this.genImage()}
154+
{this.genPlaceholder()}
155155
</div>
156156
);
157157
}

src/rate/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export default createComponent({
136136
return this.allowHalf ? 0.5 : 1;
137137
},
138138

139-
renderStar(status, index) {
139+
genStar(status, index) {
140140
const { icon, color, count, voidIcon, disabled, voidColor, disabledColor } = this;
141141
const score = index + 1;
142142
const isFull = status === 'full';
@@ -196,7 +196,7 @@ export default createComponent({
196196
onTouchstart={this.onTouchStart}
197197
onTouchmove={this.onTouchMove}
198198
>
199-
{this.list.map((status, index) => this.renderStar(status, index))}
199+
{this.list.map((status, index) => this.genStar(status, index))}
200200
</div>
201201
);
202202
}

src/sku/components/SkuImgUploader.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default createComponent({
4444
this.$toast(t('oversize', this.maxSize));
4545
},
4646

47-
renderUploader(content, disabled = false) {
47+
genUploader(content, disabled = false) {
4848
return (
4949
<Uploader
5050
class={bem('uploader')}
@@ -60,7 +60,7 @@ export default createComponent({
6060
);
6161
},
6262

63-
renderMask() {
63+
genMask() {
6464
return (
6565
<div class={bem('mask')}>
6666
{this.uploadFail
@@ -80,7 +80,7 @@ export default createComponent({
8080
render() {
8181
return (
8282
<div class={bem()}>
83-
{this.value && this.renderUploader(
83+
{this.value && this.genUploader(
8484
[
8585
<img src={this.value} />,
8686
<Icon
@@ -94,15 +94,15 @@ export default createComponent({
9494
true
9595
)}
9696

97-
{this.paddingImg && this.renderUploader(
97+
{this.paddingImg && this.genUploader(
9898
[
9999
<img src={this.paddingImg} />,
100-
this.renderMask()
100+
this.genMask()
101101
],
102102
!this.uploadFail
103103
)}
104104

105-
{!this.value && !this.paddingImg && this.renderUploader(
105+
{!this.value && !this.paddingImg && this.genUploader(
106106
<div class={bem('trigger')}>
107107
<Icon name="photograph" size="22px" />
108108
</div>

src/swipe/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ export default createComponent({
312312
}
313313
},
314314

315-
renderIndicator() {
315+
genIndicator() {
316316
const { count, activeIndicator } = this;
317317
const slot = this.slots('indicator');
318318

@@ -349,7 +349,7 @@ export default createComponent({
349349
>
350350
{this.slots()}
351351
</div>
352-
{this.renderIndicator()}
352+
{this.genIndicator()}
353353
</div>
354354
);
355355
}

src/tabs/Content.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default createComponent({
5353
}
5454
},
5555

56-
renderChildren() {
56+
genChildren() {
5757
if (this.animated) {
5858
return (
5959
<div class={bem('track')} style={this.style}>
@@ -72,7 +72,7 @@ export default createComponent({
7272
class={bem('content', { animated: this.animated })}
7373
{...{ on: this.listeners }}
7474
>
75-
{this.renderChildren()}
75+
{this.genChildren()}
7676
</div>
7777
);
7878
}

0 commit comments

Comments
 (0)