Visual Studio Code 启用建议代码 JavaScript,就像 WebStorm 中一样

问题描述 投票:0回答:2

我正在寻找一个解决方案,如何启用 JavaScript 代码的所有建议,例如我在 VSC 和 WebStorm 中编写相同的代码:

在 WebStorm 中我有所有与单词

remov
匹配的建议,但在 VSC 中我有信息:
No suggestions.

我尝试使用这个问题的答案,但没有任何作用:

如何在 Visual Studio Code 中启用 JavaScript 智能感知

VSCode IntelliSense 自动完成 JavaScript

VS Code 根据文件中的单词自动完成

我有VSC 1.24.0版本

我的settings.json文件:

{
    "php.validate.executablePath": "C:\\php7\\php.exe",
    "workbench.iconTheme": "vscode-icons",
    "files.associations": {
        "*.ejs": "html",
        "*.js": "javascript"
    },
    "css.fileExtensions": [
        "css",
        "scss"
    ],
    "sublimeTextKeymap.promptV3Features": true,
    "editor.multiCursorModifier": "ctrlCmd",
    "editor.snippetSuggestions": "top",
    "editor.formatOnPaste": true,
    "editor.wordWrap": "on",
    "window.menuBarVisibility": "toggle",
    "window.zoomLevel": 0,
    "workbench.colorTheme": "Afterglow",
    "editor.fontSize": 14,
    "editor.renderIndentGuides": false,
    "files.autoSave": "onFocusChange",
    "vsicons.dontShowNewVersionMessage": true,
    "editor.quickSuggestions": {
        "other": true,
        "comments": true,
        "strings": true
    },
    "editor.quickSuggestionsDelay": 1,
    "editor.suggestOnTriggerCharacters": true,
    "editor.wordBasedSuggestions": true,
    "editor.parameterHints": true
}

编辑:

我使用的所有代码:

document.addEventListener("DOMContentLoaded", function () {


    function Calendar(input) {
        this.now = new Date();
        this.day = this.now.getDate();
        this.month = this.now.getMonth();
        this.year = this.now.getFullYear();

        this.input = input; 
        this.divCnt = null; 
        this.divHeader = null; 
        this.divTable = null; 
        this.divDateText = null; 
        this.divButtons = null; 


        this.init = function() {

            this.divCnt = document.createElement('div');
            this.divCnt.classList.add('calendar');

            this.divButtons = document.createElement('div');
            this.divButtons.className = "calendar-prev-next";

            this.divDateText = document.createElement('div');
            this.divDateText.className = 'date-name';

            this.divHeader = document.createElement('div');
            this.divHeader.classList.add('calendar-header');

            this.divHeader.appendChild(this.divButtons);
            this.divHeader.appendChild(this.divDateText);

            this.divHeader.appendChild();
        };

    }

});
javascript visual-studio-code webstorm
2个回答
1
投票

VS Code 的智能感知无法推断

divCnt
的类型,因为它未在构造函数中分配。您可以通过在构造函数中分配值或使用 jsdocs 来启用正确的智能感知:

function Calendar(input) {
    this.divCnt = /** @type {HTMLDivElement} */ (null);
}

根本原因是https://github.com/Microsoft/TypeScript/issues/10868


0
投票

只需安装node.js@types/jquery,然后重新启动你的电脑。

© www.soinside.com 2019 - 2024. All rights reserved.