npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

numeral-rc

v0.0.2

Published

金额格式化组件,提供数字转中文大写 例如:¥200034.12 => ¥贰拾万零叁拾肆元壹角贰分

Readme

numeral-react

Getting Started

Install dependencies,

$ npm i numeral-rc
or
$ yarn add numeral-rc

API

Demo:

import { Card, Modal, Table, Tag } from 'antd';
import React, { useState } from 'react';
import { Numeral } from 'numeral-react';
import 'antd/dist/antd.css';

export default () => {
  const columns = [
    {
      title: '商品',
      align: 'left',
      dataIndex: 'name',
    },
    {
      title: '数量',
      align: 'right',
      dataIndex: 'numbers',
      render: (text) => <Numeral.Thousand value={text} />,
    },
    {
      title: '金额',
      dataIndex: 'money',
      align: 'right',
      render: (text) => <Numeral value={text} unit="元" />,
    },
  ];

  const columns2 = [
    {
      title: '商品',
      align: 'left',
      dataIndex: 'name',
    },
    {
      title: '数量',
      align: 'right',
      dataIndex: 'numbers',
      render: (text) => <Numeral type="thousand" unit="件" value={text} />,
    },
    {
      title: '金额',
      dataIndex: 'money',
      align: 'right',
      render: (text) => <Numeral.TT value={text} unit="万元" />,
    },
  ];

  const columns3 = [
    {
      title: '商品',
      align: 'left',
      dataIndex: 'name',
    },
    {
      title: '数量',
      align: 'right',
      dataIndex: 'numbers',
      render: (text) => <Numeral.Thousand value={text} />,
    },
    {
      title: '金额',
      dataIndex: 'money',
      align: 'right',
      render: (text) => (
        <Numeral.Defined
          render={(currency, value, unit) => (
            <div>
              <Tag color="cyan">{`${currency}${value}${unit}`}</Tag>
            </div>
          )}
          decimals={3}
          value={text}
          unit="美元"
          currency="$"
        />
      ),
    },
  ];

  const columns4 = [
    {
      title: '商品',
      align: 'left',
      dataIndex: 'name',
    },
    {
      title: '数量',
      align: 'right',
      dataIndex: 'numbers',
      render: (text) => <Numeral.Thousand value={text} />,
    },
    {
      title: '金额',
      dataIndex: 'money',
      align: 'right',
      render: (text) => <Numeral.Defined decimals={3} value={text} unit="" />,
    },
  ];

  const columns5 = [
    {
      title: '商品',
      align: 'left',
      dataIndex: 'name',
    },
    {
      title: '数量',
      align: 'right',
      dataIndex: 'numbers',
      render: (text) => <div>{Numeral.numberValue(text, 0, 1)}</div>,
    },
    {
      title: '金额',
      dataIndex: 'money',
      align: 'right',
      render: (text) => <div>{Numeral.numberValue(text, 2, 1)}</div>,
    },
  ];

  const dataArray = () => {
    const data = [];
    for (let i = 0; i < 1; i++) {
      data.push({
        key: i,
        name: `产品 ${i}`,
        numbers: 1000,
        money: 23004.34,
      });
    }
    return data;
  };

  return (
    <>
      <Card>
        <h3>普通的金额格式化 例如:2000 -- 2,000.00 </h3>
        <Table pagination={false} columns={columns} dataSource={dataArray()} />
      </Card>
      <Card>
        <h3>格式转行为万元 例如:20000 -- 2.000000</h3>
        <Table pagination={false} columns={columns2} dataSource={dataArray()} />
      </Card>
      <Card>
        <h3>格式自定义 需要转为保留3位小数 使用render自定义渲染 </h3>
        <Table pagination={false} columns={columns3} dataSource={dataArray()} />
      </Card>
      <Card>
        <h3>错误格式数据-原始数据返回 ***金额=fds-9383</h3>
        <Table
          pagination={false}
          columns={columns4}
          dataSource={[
            {
              key: 333,
              name: `产品 ${0}`,
              numbers: Math.floor(Math.random() * 100000),
              money: 'fds-9383',
            },
          ]}
        />
      </Card>
      <Card>
        <h3>不直接使用Numeral组件 使用Numeral.numberValue转换</h3>
        <Table
          pagination={false}
          columns={columns5}
          dataSource={[
            {
              key: 333,
              name: `产品 ${0}`,
              numbers: Math.floor(Math.random() * 100000),
              money: '1000',
            },
          ]}
        />
      </Card>
      <Card>
        <h3>¥200034.12 => ¥{Numeral.numberMoneyToChinese(200034.12)}</h3>
      </Card>
    </>
  );
};