2016-07-20 4 views
0

저는 Visual Studio를 사용하여 javascript/jquery를 작성하고 있습니다. 예, 내가 입력 : javascript/jquery에서 함수 선언 및 재정화

$('#selector').text('foo') 

는 내가 text을 선택하고 F12를 누릅니다.

'text': function() { 
    /// <signature> 
    /// <summary>Set the content of each element in the set of matched elements to the specified text.</summary> 
    /// <param name="textString" type="String">A string of text to set as the content of each matched element.</param> 
    /// <returns type="jQuery" /> 
    /// </signature> 
    /// <signature> 
    /// <summary>Set the content of each element in the set of matched elements to the specified text.</summary> 
    /// <param name="function(index, text)" type="Function">A function returning the text content to set. Receives the index position of the element in the set and the old text value as arguments.</param> 
    /// <returns type="jQuery" /> 
    /// </signature> 
    } 

나는 그것이 단지 기능에 대한 설명이 포함되어 있는지 알고 VS는 fucntion에 아래로 스크롤 자동으로 나에게 파일 jquery-2.2.3.intellisense.js을 표시하고있다. 나는 그것을하고 싶다.

장소의 설명이있는 기능을 선언하고 다른 위치에서 재정의 (구현)하십시오. 이처럼 : I 입력 이제

// first 
var Add = function (a, b) { 
    /// <signature> 
    /// <sumary>Add 2 numbers</sumary> 
    /// <returns type="Number" /> 
    /// </signature> 
}; 

// second 
@override 
@** 
* Add 2 numbers 
* @param {Number} a: Number a 
* @param {Number} b: Number b 
* @return {Number} 
*/ 
var Add = function (a, b) { 
    return a + b 
}; 

:

var sum = Add(2, 3); 

은 내가 VS는 the first 기능 (두 번째되지 않음)에 충돌 할 원하는, Add을 선택하고 F12를 누릅니다.

그래서 내 질문 : 어떻게 할 수 있습니까?

나는 파일 another.js에서 intellisense.annotate(jQuery, {});

intellisense.annotate(jQuery, { 
    'Add': function() { 
     /// <signature> 
     /// <summary>Add 2 numbers</summary> 
     /// <param name="a" type="Number">Number a</param> 
     /// <param name="b" type="Number">Number b</param> 
     /// <returns type="Number" /> 
     /// </signature> 
    } 
}); 

에 파일 jquery-2.2.3.intellisense.js 및 기능을 엽니 다 해봤

+0

이 작업은 수행 할 수 없습니다. – underscore

+0

'visual-studio'로 질문에 태그를 붙여야합니다. 태그를 올바르게 사용하면 다른 사람들이 당신에게 대답하는 데 도움이됩니다. – cezar

답변

0

:

$.fn.extend({ 
    /** 
     * Add 2 numbers 
     * param {Number} a: Number a 
     * param {Number} a: Number b 
     * return {Number} 
    */ 
    Add: function (a, b) { 
     return a + b 
    } 
}); 

테스트 :

$('#selector').Add(2, 3) 

선택 Add 누릅니다 F12 VS는 함수 intellisense를 올바르게 가리 킵니다 (함수 Add의 구현은이 경우 아무 것도 의미하지 않지만).