【问题标题】:How to use Numeral.js or any JS plugins in React-Native App?如何在 React-Native App 中使用 Numeral.js 或任何 JS 插件?
【发布时间】:2019-01-05 01:52:25
【问题描述】:

我需要在 React-Native 中将数字更改为货币格式 这在我的情况下不起作用:

import Numeral from "numeral";
Numeral(100).format("$0.00")

它输出:Metro Bundler 遇到内部错误。 我知道 Numeral 不是为 React-Native 构建的,但是否有解决方法或任何替代方法?

【问题讨论】:

  • 文档状态 (numeraljs.com/#use-it):npm install numeral --dev,然后是 const Numeral = require('numeral');

标签: reactjs react-native numeral.js


【解决方案1】:

这里是使用数字库的步骤:

  1. 在您的应用程序文件夹中输入npm install --save numeral
  2. 像这样导入数字库import numeral from 'numeral'
  3. 像这样在你想放的地方使用numeral(100).format('$0,0.00')

您可以从网站http://numeraljs.com/ 看到另一种格式和文档

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-21
    • 2020-12-16
    • 2018-11-07
    • 2017-10-20
    相关资源
    最近更新 更多