Flex NumberFormatter 数值的格式化

Posted on 2013-07-25 15:27  诸葛小北  阅读(361)  评论(0编辑  收藏  举报
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
    <fx:Declarations>
        <fx:XML id="myData" xmlns="">
            <root>
                <forsale>
                    <item name="weight" value="32.5658"/>
                </forsale>
            </root>
        </fx:XML>
        <mx:NumberFormatter id="fmtNumber" precision="2" rounding="nearest"/>
    </fx:Declarations>
    <s:Label text="Weight {fmtNumber.format(myData.forsale.item.@value)}千克"/>
</s:Application>
View Code

rouding 属性是舍入法

 

Copyright © 2024 诸葛小北
Powered by .NET 8.0 on Kubernetes