mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-23 18:00:27 +08:00
fix(SubmitBar): fix decimal-length bug (#5224)
This commit is contained in:
parent
41824d7afa
commit
00c4e488c9
@ -41,12 +41,17 @@ function SubmitBar(
|
|||||||
function Text() {
|
function Text() {
|
||||||
if (typeof price === 'number') {
|
if (typeof price === 'number') {
|
||||||
const priceArr = (price / 100).toFixed(props.decimalLength).split('.');
|
const priceArr = (price / 100).toFixed(props.decimalLength).split('.');
|
||||||
|
const decimalStr = props.decimalLength ? `.${priceArr[1]}` : '';
|
||||||
return (
|
return (
|
||||||
<div style={{ textAlign: props.textAlign ? props.textAlign : '' }} class={bem('text')}>
|
<div
|
||||||
|
style={{ textAlign: props.textAlign ? props.textAlign : '' }}
|
||||||
|
class={bem('text')}
|
||||||
|
>
|
||||||
<span>{props.label || t('label')}</span>
|
<span>{props.label || t('label')}</span>
|
||||||
<span class={bem('price')}>
|
<span class={bem('price')}>
|
||||||
{props.currency}
|
{props.currency}
|
||||||
<span class={bem('price', 'integer')}>{priceArr[0]}</span>.{priceArr[1]}
|
<span class={bem('price', 'integer')}>{priceArr[0]}</span>
|
||||||
|
{decimalStr}
|
||||||
</span>
|
</span>
|
||||||
{props.suffixLabel && (
|
{props.suffixLabel && (
|
||||||
<span class={bem('suffix-label')}>{props.suffixLabel}</span>
|
<span class={bem('suffix-label')}>{props.suffixLabel}</span>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user