Skip to content

Commit aba5f59

Browse files
authored
[new feature] Sku: support custom placeholder (youzan#3864)
1 parent 511087b commit aba5f59

5 files changed

Lines changed: 10 additions & 9 deletions

File tree

src/sku/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ sku: {
211211
multiple: '0',
212212
name: 'Message',
213213
type: 'text',
214-
required: '1'
214+
required: '1'
215+
placeholder: ''
215216
}
216217
],
217218
hide_stock: false
@@ -278,7 +279,7 @@ messageConfig: {
278279
},
279280
// max file size (MB)
280281
uploadMaxSize: 3,
281-
// placehold config
282+
// placeholder config
282283
placeholderMap: {
283284
text: 'xxx',
284285
tel: 'xxx',

src/sku/README.zh-CN.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@ sku: {
221221
multiple: '0', // 留言类型为 text 时,是否多行文本。'1' 表示多行
222222
name: '留言', // 留言名称
223223
type: 'text', // 留言类型,可选: id_no(身份证), text, tel, date, time, email
224-
required: '1' // 是否必填 '1' 表示必填
224+
required: '1', // 是否必填 '1' 表示必填
225+
placeholder: '' // 可选值,占位文本
225226
}
226227
],
227228
hide_stock: false // 是否隐藏剩余库存
@@ -290,7 +291,7 @@ messageConfig: {
290291
},
291292
// 最大上传体积 (MB)
292293
uploadMaxSize: 3,
293-
// placehold配置
294+
// placeholder 配置
294295
placeholderMap: {
295296
text: 'xxx',
296297
tel: 'xxx',

src/sku/components/SkuMessages.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export default createComponent({
8585
getPlaceholder(message) {
8686
const type = +message.multiple === 1 ? 'textarea' : message.type;
8787
const map = this.messageConfig.placeholderMap || {};
88-
return map[type] || PLACEHOLDER[type];
88+
return message.placeholder || map[type] || PLACEHOLDER[type];
8989
},
9090

9191
validateMessages() {

src/sku/type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export type SkuMessageData = {
3939
required?: string;
4040
datetime?: string;
4141
multiple?: string;
42+
placeholder?: string;
4243
};
4344

4445
export type SkuGoodsData = {

src/utils/types.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import { InjectOptions, PropsDefinition } from 'vue/types/options';
33

44
export type EventHandler = (event: Event) => void;
55

6-
export type ObjectIndex = {
7-
[key: string]: any;
8-
};
6+
export type ObjectIndex = Record<string, any>;
97

108
export type ScopedSlot<Props = any> = (props?: Props) => VNode[] | VNode | undefined;
119

@@ -22,7 +20,7 @@ export type ModelOptions = {
2220
event?: string;
2321
};
2422

25-
export type DefaultProps = Record<string, any>;
23+
export type DefaultProps = ObjectIndex;
2624

2725
export type FunctionComponent<Props = DefaultProps, PropDefs = PropsDefinition<Props>> = {
2826
(h: CreateElement, props: Props, slots: ScopedSlots, context: RenderContext<Props>):

0 commit comments

Comments
 (0)