简体   繁体   English

编码样式-命名约定-常量-JQuery使用哪种样式?

[英]Coding Style - Naming Conventions - Constants - What style does JQuery use?

I'd like to use the style JQuery uses: 我想使用JQuery使用的样式:

I looked here: 我在这里看:

JQuery Coding Style jQuery编码风格

but could not find it. 但找不到。 Is it the same as PHP Zend style - All caps w/ underscores to seperate names? 是否与PHP Zend样式相同-所有大写字母都带有下划线以分隔名称?

I dowloaded the latest verion of JQuery and ran a search for constants but nothing came up. 我下载了最新版本的JQuery,并搜索了常量,但没有任何反应。

Here is how I do my constants. 这是我做常量的方法。

var Constant = 
{

/**
 *      Code Configuration
 */

    validate:                   1,

/**
 *      Paths Configuration
 */
    root:                       '',
    pictures_path:              '../pictures/',
    images_path:                '../images/',
    txt_path:                   '../text/',
    favicon:                    '../images/' + 'logo_small.ico',
    gateway_path:               'class.ControlEntry.php',

/**
 *      General
 */

    enter_key:                  13,
    second :                    1000,
    minute:                     60,
    hour:                       3600,
    day:                        43200,
    start:                      'hide_1',
    aml: 
    {
        "pass":                 0,
        "fail":                 1, 
        "undefinedU":           2
    }
};

If you look through the jQuery API (and even the name jQuery itself), it is pretty noticeable that jQuery uses camelCase most of the time. 如果您浏览jQuery API(甚至是jQuery本身的名称),则很明显jQuery大部分时间都使用camelCase

Here are a few examples. 这里有一些例子。

All methds that are a result of seleting an element are camel-case: 分离元素的所有方法都是驼峰式的:
addClass, removeClass, ajaxComplete, ajaxSend, after, add, append, appendTo addClass,removeClass,ajaxComplete,ajaxSend,之后,添加,追加,appendTo

Most methods/properties that are members of jQuery are also camel-case, with a few exceptions. jQuery的大多数方法/属性都是驼峰式的,只有少数例外。
ajax, ajaxSetup, boxModel, browser, contains, cssHooks, data ajax,ajaxSetup,boxModel,浏览器,包含,cssHooks,数据

The exceptions are: 例外是:
Deferred because it returns a new deferred object, and Callbacks because it returns a new Callbacks object. 推迟是因为它返回了一个新的延迟对象,而回调是因为它返回了一个新的Callbacks对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM