Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/434.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在javascript中将数字格式化为货币字符串?_Javascript - Fatal编程技术网

在javascript中将数字格式化为货币字符串?

在javascript中将数字格式化为货币字符串?,javascript,Javascript,我想用JavaScript格式化一个价格 ->250012 应该是 ->2.500,12 看法 @LabelFor(model=>model.Price,htmlAttributes:new{@class=“controllabel col-md-2”}) @EditorFor(model=>model.Price,new{htmlAttributes=new{@class=“form control”}) @Html.ValidationMessageFor(model=>model.Pri

我想用JavaScript格式化一个价格

->250012

应该是

->2.500,12

看法


@LabelFor(model=>model.Price,htmlAttributes:new{@class=“controllabel col-md-2”})
@EditorFor(model=>model.Price,new{htmlAttributes=new{@class=“form control”})
@Html.ValidationMessageFor(model=>model.Price,“,new{@class=“text danger”})
>常数编号=250012;
>(数字/100)。toLocaleString('de-de')
< "2.500,12"

有关浏览器支持和更多信息,请参阅。您确定不想用Razor而不是Javascript格式化价格吗?使用搜索功能:是。我已经调查过了,但我做不到。
 <div class="form-group">
        @Html.LabelFor(model => model.Price, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.Price, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.Price, "", new { @class = "text-danger" })
        </div>
    </div>
> const number = 250012;
> (number/100).toLocaleString('de-DE')
< "2.500,12"