5

我正在使用 Globalize jQuery 插件在我的 MVC 网站的客户端进行全球化(正确的数字和日期格式)。所以我已经下载了该插件,并在验证 js 文件本身之后包含了以下 javascript 文件(我之前也尝试过放置 Globalize 文件,但没有任何运气):

<script src="/Scripts/globalize.js"></script>
<script src="/Scripts/jquery.validate.globalize.min.js"></script>
<script src="/Scripts/globalize/globalize.culture.da-DK.js"></script>

但是当运行应用程序时,我得到了错误

Globalize.addCultureInfo 不是函数

我无法弄清楚原因是什么

4

2 回答 2

1

根据 Globalize 库本身的文档,这个功能在 1.x 版本中已经被移除。此功能在 0.x 版本中存在

此方法由Globalize.loadMessages( json ). 如果您将它用于消息翻译以外的任何内容,您可能还需要使用Globalize.load.

于 2017-02-02T12:28:25.737 回答
0

可能是因为函数 addCulterInfo 没有在 globalize.js 文件中定义。前段时间我在我的一个项目中使用了类似的东西。我希望它有帮助:

Globalize.addCultureInfo = function( cultureName, baseCultureName, info ) {
    var base = {},
            isNew = false;
    if ( typeof cultureName !== "string" ) {
            // cultureName argument is optional string. If not specified, assume info is first
            // and only argument. Specified info deep-extends current culture.
            info = cultureName;
            cultureName = this.culture().name;
            base = this.cultures[ cultureName ];
    } else if ( typeof baseCultureName !== "string" ) {
            // baseCultureName argument is optional string. If not specified, assume info is second
            // argument. Specified info deep-extends specified culture.
            // If specified culture does not exist, create by deep-extending default
            info = baseCultureName;
            isNew = ( this.cultures[ cultureName ] == null );
            base = this.cultures[ cultureName ] || this.cultures[ "default" ];
    } else {
            // cultureName and baseCultureName specified. Assume a new culture is being created
            // by deep-extending an specified base culture
            isNew = true;
            base = this.cultures[ baseCultureName ];
    }
    this.cultures[ cultureName ] = extend(true, {},
            base,
            info
    );
    // Make the standard calendar the current culture if it's a new culture
    if ( isNew ) {
            this.cultures[ cultureName ].calendar = this.cultures[ cultureName ].calendars.standard;
    }
};
于 2016-12-22T15:32:56.827 回答