如何安全地将Intl.numberFormat反向还原为原始数字格式

时间:2019-11-29 12:45:01

标签: flutter dart

我的字符串格式为

interface propsInterface {
  title: string
};

interface stateInterface {
  visibility: boolean
};

class Below extends React.Component <propsInterface, stateInterface > {

 constructor(props) {
    super(props);
    this.state = { visible: true};
 }
  
 render() {
  if (this.state.visible === true) {
    return (
     <main>
      <div>{this.props.title}</div>
     </main>
   );
  } else {
    return (<div></div>);
  }
  }  
 };
  
  
 ReactDOM.render(
  <Below title="Below component." />,
   document.getElementById('root'));

使用dart intl NumberFormat(“#,## 0.00”,“ ko-KR”)进行格式化。

如何将它们还原为原始数字?:

<div id="root"></div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>

1 个答案:

答案 0 :(得分:1)

使用parse的{​​{1}}方法:

NumberFormat
final format = NumberFormat("#,##0.00", "ko-KR");
final String str = format.format(20000);
print(str);
final num number = format.parse(string);
print(number);