Skip to content

Price 价格

介绍

用于展示价格。

TIP

阅读该组件文档前请确保已认真阅读快速上手章节的每一个字

引入

ts
import { IBestPrice } from "@ibestservices/ibest-ui-v2";

代码演示

基础用法

基础用法

点我查看代码
ts
@Entry
@ComponentV2
struct DemoPage {
  @Local value: number = 0
  build() {
    Column() {
      IBestPrice({
        value: this.value
      })
    }
  }
}

小数点位数

小数点位数

点我查看代码
ts
@Entry
@ComponentV2
struct DemoPage {
  @Local value: number = 8888
  build() {
    Column() {
      IBestPrice({
        value: this.value,
        decimal: 0
      })
    }
  }
}

划线价

划线价

点我查看代码
ts
@Entry
@ComponentV2
struct DemoPage {
  @Local value: number = 8888
  build() {
    Column() {
      IBestPrice({
        value: this.value,
        decimal: 0,
        strikeThrough: true
      })
    }
  }
}

货币符号

货币符号

点我查看代码
ts
@Entry
@ComponentV2
struct DemoPage {
  @Local value: number = 8888.68
  build() {
    Column() {
      IBestPrice({
        value: this.value,
        symbol: "$"
      })
    }
  }
}

货币符号位置

货币符号位置

点我查看代码
ts
@Entry
@ComponentV2
struct DemoPage {
  @Local value: number = 8888.68
  build() {
    Column() {
      IBestPrice({
        value: this.value,
        symbol: "RMB",
        symbolPosition: "right"
      })
    }
  }
}

千位分隔

千位分隔

点我查看代码
ts
@Entry
@ComponentV2
struct DemoPage {
  @Local value: number = 8888.6888
  build() {
    Column() {
      IBestPrice({
        value: this.value,
        decimal: 3,
        thousand: true
      })
    }
  }
}

自定义样式

自定义样式

点我查看代码
ts
@Entry
@ComponentV2
struct DemoPage {
  @Local value: number = 8888.68
  build() {
    Column() {
      IBestPrice({
        value: this.value,
        symbolFontSize: 20,
        integerFontSize: 20,
        decimalPointFontSize: 18,
        decimalFontSize: 18,
        color: "#1989fa"
      })
    }
  }
}

API

@Props

参数说明类型默认值
value显示价格string | number0
symbol货币符号ResourceStr
symbolPosition货币符号位置, 可选值 left rightstringleft
decimal小数位位数number2
thousand是否按照千分位显示booleanfalse
strikeThrough文本装饰线booleanfalse
symbolFontSize符号字体大小string | number14
integerFontSize整数部分字体大小string | number16
decimalPointFontSize小数点字体大小string | number14
decimalFontSize小数部分字体大小string | number14
color随机背景色ResourceColor#ee0a24