Skip to content
On this page

Commerce

用于生成商业和产品相关条目的模块

department

返回商店内的部门

Available since v3.0.0

Returns: string

ts
faker.commerce.department(): string
faker.commerce.department() // => "Toys"
faker.commerce.department() // 'Garden'

price

生成介于最小值和最大值(含)之间的价格

Available since v3.0.0

Parameters

NameTypeDefaultDescription
minnumber1

The minimum price.

maxnumber1000

The maximum price.

decnumber2

The number of decimal places.

symbolstring''

The currency value to use.

Returns: string

ts
faker.commerce.price(min: number = 1, max: number = 1000, dec: number = 2, symbol: string = ''): string
faker.commerce.price() // => "549.00"
faker.commerce.price() // 828.00
faker.commerce.price(100) // 904.00
faker.commerce.price(100, 200) // 154.00
faker.commerce.price(100, 200, 0) // 133
faker.commerce.price(100, 200, 0, '$') // $114

product

返回简短的产品名称

Available since v3.0.0

Returns: string

ts
faker.commerce.product(): string
faker.commerce.product() // => "Towels"
faker.commerce.product() // 'Computer'

productAdjective

返回描述产品的形容词

Available since v3.0.0

Returns: string

ts
faker.commerce.productAdjective(): string
faker.commerce.productAdjective() // => "Bespoke"
faker.commerce.productAdjective() // 'Handcrafted'

productDescription

返回产品说明

Available since v5.0.0

Returns: string

ts
faker.commerce.productDescription(): string
faker.commerce.productDescription() // => "The Football Is Good For Training And Recreati...
faker.commerce.productDescription() // 'Andy shoes are designed to keeping...'

productMaterial

返回产品的材料

Available since v3.0.0

Returns: string

ts
faker.commerce.productMaterial(): string
faker.commerce.productMaterial() // => "Granite"
faker.commerce.productMaterial() // 'Rubber'

productName

生成随机描述性产品名称

Available since v3.0.0

Returns: string

ts
faker.commerce.productName(): string
faker.commerce.productName() // => "Bespoke Rubber Fish"
faker.commerce.productName() // 'Incredible Soft Gloves'

Released under the MIT License,本站仅做翻译,如有错误,请向我反馈 QQ:385858750