简体   繁体   English

React/JS 没有显示可能性(智能感知)VSCODE

[英]React/JS not showing possibilities (intellisense) VSCODE

I am currently learning React in Visual Studio Code.我目前正在 Visual Studio Code 中学习 React。 However, it does not seem to be doing the intellisense correctly.但是,它似乎没有正确执行智能感知。 I might be missing something, or be doing something wrong.我可能遗漏了什么,或者做错了什么。 在此处输入图片说明

I am expecting it to show " this.setState ".我期待它显示“ this.setState ”。 If I write the code manually it works, but it is very inconvenient to fully write out these names.如果我手动编写代码它可以工作,但是完全写出这些名称非常不方便。 Or to check the possibilities.或者检查可能性。

I've tried changing the option on the bottom from HTML to JSBabel.我尝试将底部的选项从 HTML 更改为 JSBabel。 It does change the way it does the intellisense, however not quite correct yet.它确实改变了它执行智能感知的方式,但还不太正确。 If I choose for JSbabel it does the autocomplete for me.如果我选择 JSbabel,它会为我自动完成。 So when I it automatically closes(which is nice), but when the correct option does not show up it will autocomplete the wrong things.所以当我自动关闭时(这很好),但是当正确的选项没有出现时,它会自动完成错误的事情。 And HTML does not autocomplete for me, neither does it sometimes show the right options.而且 HTML 不会自动完成,有时也不会显示正确的选项。

I've been struggling with this for a while and I haven't found a way to do this yet.我已经为此苦苦挣扎了一段时间,但我还没有找到一种方法来做到这一点。

Try moving your code out into a JavaScript file.尝试将您的代码移出 JavaScript 文件。 VS Code's IntelliSense for JavaScript within html script blocks is quite limited, and it does not understand references to scripts. VS Code 在 html 脚本块中对 JavaScript 的 IntelliSense 非常有限,它不理解对脚本的引用。 https://github.com/microsoft/vscode/issues/26338 tracks this but it unlikely to be fully addressed given the complexity of the problem https://github.com/microsoft/vscode/issues/26338跟踪了这一点,但鉴于问题的复杂性,不太可能完全解决

But in a normal JS file, you should get full react IntelliSense once you add a react import (You can also follow the steps in this answer to manually setup react intellisense)但是在普通的 JS 文件中,一旦添加了 react 导入,您就应该获得完整的 react IntelliSense(您也可以按照此答案中的步骤手动设置 react intellisense)

use a constructor, and assign default value.使用构造函数,并分配默认值。 Also for valide value, you can use jsdoc.同样对于验证值,您可以使用 jsdoc。 在此处输入图片说明

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

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