Skip to content

t-text-price

TextPrice 价格文本

组件介绍

t-text-price 是用于格式化显示金额的文本组件,支持自定义货币符号、小数位数和千分位分隔符,适用于商品价格、账单金额等场景。

平台兼容

HarmonyH5AndroidiOS小程序UTS

基础用法

基础用法参考 demo/text-price/text-price.uvue

vue
<template>
  <view class="text-price-demo">
    <!-- 默认格式 -->
    <t-text-price text="1234567.89"></t-text-price>
    
    <!-- 显示两位小数 -->
    <t-text-price text="1234567.89" :decimals="2"></t-text-price>
    
    <!-- 自定义货币符号 -->
    <t-text-price text="1234567.89" decimalPoint="$"></t-text-price>
    
    <!-- 整数金额 -->
    <t-text-price text="1234567.89" :decimals="0"></t-text-price>
  </view>
</template>

<style scoped>
.text-price-demo {
  padding: 40rpx;
}
</style>

Props

属性名说明类型默认值
text需要格式化的金额string | number''
decimals显示的小数位数number0
decimalPoint货币符号string'¥'
path点击组件后跳转的页面路径;为空时仅响应事件string''
hover是否启用点击效果booleantrue
type组件主题类型,可选 infoprimaryerrorwarningsuccessstring''
disabled是否禁用booleanfalse
effect组件显示主题,可选 normaldarklightplainstring''
size组件尺寸,可选 largemediumsmallministring'medium'

Events

事件名说明回调参数
click点击时触发event
initFinished组件初始化完成触发组件节点信息
touchstart触摸开始时触发event
touchend触摸结束时触发event
touchmove触摸移动时触发event
touchcancel触摸取消时触发event