2

我在 .Net MVC 项目上使用此帖子Globalize error with local numbers来在 Asp Mvc 应用程序中安装新版本的 Globalize。

所以在 _Layout.cshtml 我添加了这段代码

<script>

(function () {

    $(function () {
        $.when(
              $.getJSON("/Scripts/cldr/supplemental/likelySubtags.json"),
              $.getJSON("/Scripts/cldr/main/fr/numbers.json"),
              $.getJSON("/Scripts/cldr/supplemental/numberingSystems.json"),
              $.getJSON("/Scripts/cldr/main/fr/ca-gregorian.json"),
              $.getJSON("/Scripts/cldr/main/fr/timeZoneNames.json"),
              $.getJSON("/Scripts/cldr/supplemental/timeData.json"),
              $.getJSON("/Scripts/cldr/supplemental/weekData.json")
            ).then(function () {

                // Normalize $.get results, we only need the JSON, not the request statuses.
                return [].slice.apply(arguments, [0]).map(function (result) {
                    return result[0];
                });

            }).then(Globalize.load).then(function () {
                var culture = "fr";
                Globalize.locale(culture);
            });
    });
})();


</script>

但是当我在服务器中部署时它不起作用。

Ps:我在我的 web.config 中添加了这个

<system.webServer>
...
<staticContent>
  <remove fileExtension=".json"/>
  <mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>

</system.webServer>

请帮忙。

4

1 回答 1

0

试试这个方法:

$.getJSON(@Url.Content("~/Scripts/cldr/supplemental/likelySubtags.json")),
$.getJSON(@Url.Content("~/Scripts/cldr/main/fr/numbers.json")),...

可能需要用双引号括起来,只是玩一点,@Url.Content但我相信它会解决你的问题

$.getJSON("@Url.Content("~/Scripts/cldr/supplemental/likelySubtags.json")"),
$.getJSON("@Url.Content("~/Scripts/cldr/main/fr/numbers.json")"),...
于 2016-06-05T14:21:01.987 回答