小编Fei*_*ell的帖子

VS Code 中的 jsDoc @callback

有没有办法@callback在VS Code中使用jsDoc的标签?

我尝试了从回调标签jsDoc 文档中截取的以下代码:

/**
 * @class
 */
function Requester() {}

/**
 * Send a request.
 * @param {requestCallback} cb - The callback that handles the response.
 */
Requester.prototype.send = function(cb) {
    // code
};

/**
 * This callback is displayed as a global member.
 * @callback requestCallback
 * @param {number} responseCode
 * @param {string} responseMessage
 */
Run Code Online (Sandbox Code Playgroud)

但是 VS Code 似乎没有正确解释标签,你的参数类型仍然存在,any并且函数的工具提示中没有提到回调定义。

是否有任何解决方法/插件可以启用此功能?

javascript jsdoc

3
推荐指数
1
解决办法
2346
查看次数

为js对象分配setter/getter

我试图为我的js"class"分配一个setter:

function testing(){
    this.value = "content";
    set a(b){
        this.value = b;
    };
}
var test1 = new testing();
test1.a = "nope";
Run Code Online (Sandbox Code Playgroud)

但是,如果有人告诉我正确的语法是什么,它会SyntaxError: missing ; before statement在网上抛出set a(b){

javascript setter

2
推荐指数
1
解决办法
2130
查看次数

jQuery dos内联函数无法按预期工作

我试图排除该函数(因为我已经习惯了它来自php),当你点击带有id test1的p时应该触发它.

我写了下面的jQuery

<!doctype html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>click demo</title>
        <style>
            p {
            color: red;
            margin: 5px;
            cursor: pointer;
            }
            p:hover {
            background: yellow;
            }
        </style>
        <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
        <script>
            function test1(){
                $( this ).slideUp();
            }
            $(document).ready(function(){
                    $( "#test1" ).click(test1());
            });

        </script>
    </head>
    <body>
        <p id="test1" class="test2">First Paragraph</p>
        <p>Second Paragraph</p>
        <p>Yet one more Paragraph</p>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

给定的示例适用于内联格式,但不是以这种方式编写的.谁能告诉我为什么它不起作用?

javascript jquery

0
推荐指数
1
解决办法
46
查看次数

标签 统计

javascript ×3

jquery ×1

jsdoc ×1

setter ×1