javascript 的智能提示intellisence用法
- /// <signature>
- /// <summary>Perform an asynchronous HTTP (Ajax) request.</summary>
- /// <param name="url" type="String">A string containing the URL to which the request is sent.</param>
- /// <param name="settings" type="Object">A set of key/value pairs that configure the Ajax request. All settings are optional. A default can be set for any option with $.ajaxSetup(). See jQuery.ajax( settings ) below for a complete list of all settings.</param>
- /// <returns type="jqXHR" />
- /// </signature>
- /// <signature>
- /// <summary>Perform an asynchronous HTTP (Ajax) request.</summary>
- /// <param name="settings" type="Object">A set of key/value pairs that configure the Ajax request. All settings are optional. A default can be set for any option with $.ajaxSetup().</param>
- /// <returns type="jqXHR" />
- /// </signature>
参考资料:http://msdn.microsoft.com/zh-cn/library/bb385682.aspx
对于VS强大的功能,我们还可以扩展Javascript Intellisense的智能感知的功能。有个内置的语言服务intellisense 对象
我们可以给自己的js类库添加注解:
1.命名规则 demo.js,demo.intellisense.js
2.上面2个文件必须在同一个目录下,否则不能提供数据注解的智能感知,demo.intellisense.js可以不必包含在在解决方案中
3.智能感知可能不会立马生效,要过一会儿或者重新打开解决方案才行
扩展功能:
微软设计的东西一般都遵循一个原则:惯例优先原则(也就是自动发现机制automatic discovery mechanism)
EntityFramework有这样的机制,当然Javascript的智能感知也不会例外,这也正是微软的强大之处,总的来说微软的设计和想法还是很不错的,既是:你(开发人员)要按照我的套路出牌,我(IDE)会给你很多便利。呵呵,代价就是,要学很多规矩(反正就是记不住,只能是熟能生巧了)
- /// <signature>
- /// <summary>Perform an asynchronous HTTP (Ajax) request.</summary>
- /// <param name="url" type="String">A string containing the URL to which the request is sent.</param>
- /// <param name="settings" type="Object">A set of key/value pairs that configure the Ajax request. All settings are optional. A default can be set for any option with $.ajaxSetup(). See jQuery.ajax( settings ) below for a complete list of all settings.</param>
- /// <returns type="jqXHR" />
- /// </signature>
- /// <signature>
- /// <summary>Perform an asynchronous HTTP (Ajax) request.</summary>
- /// <param name="settings" type="Object">A set of key/value pairs that configure the Ajax request. All settings are optional. A default can be set for any option with $.ajaxSetup().</param>
- /// <returns type="jqXHR" />
- /// </signature>
参考资料:http://msdn.microsoft.com/zh-cn/library/bb385682.aspx
对于VS强大的功能,我们还可以扩展Javascript Intellisense的智能感知的功能。有个内置的语言服务intellisense 对象
我们可以给自己的js类库添加注解:
1.命名规则 demo.js,demo.intellisense.js
2.上面2个文件必须在同一个目录下,否则不能提供数据注解的智能感知,demo.intellisense.js可以不必包含在在解决方案中
3.智能感知可能不会立马生效,要过一会儿或者重新打开解决方案才行
扩展功能:
微软设计的东西一般都遵循一个原则:惯例优先原则(也就是自动发现机制automatic discovery mechanism)
EntityFramework有这样的机制,当然Javascript的智能感知也不会例外,这也正是微软的强大之处,总的来说微软的设计和想法还是很不错的,既是:你(开发人员)要按照我的套路出牌,我(IDE)会给你很多便利。呵呵,代价就是,要学很多规矩(反正就是记不住,只能是熟能生巧了)
简单总结:
1. 只要我们在script文件夹里面增加了js文件,就会自动在_reference.js里面增加相应的引用
2. 我们在js的函数下面加入如下<signature>标签,就可以实现智能提示的功能,或者建立jsname.intellisence.js的文件名单独声明
$.fn.Hotkeys = function (options, param) { /// <signature> /// <summary>Hotkeys constructor function</summary> /// <param name="options" type="string">string name indicate Hotkeys plugin function name</param> /// <param name="param" type="parameter"> </param> /// <returns type="jQuery" /> /// </signature>
一组函数或方法的相关元素可以为重载函数提供文档。
下面的代码示例演示如何使用 <signature> 元素。
// Use of <signature> with externalid.
// Requires use of the <loc> tag to identify the external functions.
function illuminate(light) {
/// <signature externalid='M:Windows.Devices.Light.Illuminate()' />
/// <signature externalid='M:Windows.Devices.Light.Illuminate(System.Int32)'>
/// <param name='light' type='Number' />
/// </signature>
}
// Use of <signature> for overloads implemented in JavaScript.
function add(a, b) {
/// <signature>
/// <summary>function summary 1</summary>
/// <param name="a" type="Number">The first number</param>
/// <param name="b" type="Number">The second number</param>
/// <returns type="Number" />
/// </signature>
/// <signature>
/// <summary>function summary 2 – differ by number of params</summary>
/// <param name="a" type="Number">Only 1 parameter</param>
/// <returns type="Number" />
/// </signature>
/// <signature>
/// <summary>function summary 3 – differ by parameter type</summary>
/// <param name="a" type="Number">Number parameter</param>
/// <param name="b" type="String">String parameter</param>
/// <returns type="Number" />
/// </signature>
/// <signature>
/// <summary>function summary 4 – differ by return type</summary>
/// <param name="a" type="Number">The first number</param>
/// <param name="b" type="Number">The second number</param>
/// <returns type="String" />
/// </signature>
return a + b;
}