Skip to content

Price 商品价格 ​

介绍 ​

用来对商品价格数值的小数点前后部分应用不同样式,还支持人民币符号、千位分隔符、设置小数点位数等功能。

价格大小 ​

支持 small、normal、large 三种尺寸,默认为 normal。

html
<template>
    <mot-price :price="0" size="small" :need-symbol="false" />
    <mot-price :price="0" size="normal" :need-symbol="false" />
    <mot-price :price="0" size="large" :need-symbol="false" />
</template>

小数点位数 ​

decimal-digits 可设置小数点位数,默认展示2位小数。

html
<template>
    <mot-price :price="8888" :decimal-digits="0" />
</template>

划线价 ​

html
<template>
    <mot-price :price="8888" decimal-digits="0" size="normal" need-symbol thousands strike-through />
</template>

货币符号 ​

symbol 可设置货币符号,默认为 ¥。

html

<template>
    <mot-price :price="10010.01" symbol="¥" />
</template>

货币符号位置 ​

position 可以调整货币符号位置。

html
<template>
    <mot-price :price="8888.01" position="after" symbol="元" />
</template>

千位分隔 ​

thousands 可以按照千分号形式显示。

html
<template>
    <mot-price :price="15213.1221" :decimal-digits="3" :thousands="true" />
</template>

API ​

Props ​

参数说明类型默认值
price价格数量number | string0
need-symbol是否需要加上 symbol 符号booleantrue
symbol符号类型string&yen;
decimal-digits小数位位数number2
thousands是否按照千分号形式显示booleanfalse
position符号显示在价格前或者后,before、afterstringbefore
size价格尺寸,small、normal、largestringnormal
strike-through是否展示划线价Booleanfalse

主题定制 ​

样式变量 ​

组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 ConfigProvider 组件。

名称默认值
--mot-price-symbol-big-size18px
--mot-price-big-size24px
--mot-price-decimal-big-size18px
--mot-price-symbol-medium-size14px
--mot-price-medium-size16px
--mot-price-decimal-medium-size14px
--mot-price-symbol-small-size10px
--mot-price-small-size12px
--mot-price-decimal-small-size10px

MIT Licensed