[英]React suggestions and autocomplete does not work for files with js extension in VSCode
I need to enable React related suggestions and autocomplete but in files with .js
extension in Visual Studio Code.我需要在 Visual Studio Code 中启用与 React 相关的建议和自动完成功能,但在扩展名为
.js
的文件中。 The only way to make it working for me is to change extension from .js
to .jsx
.使它对我有用的唯一方法是将扩展名从
.js
更改为.jsx
。 I tried everything described in this post but nothing worked for me.我尝试了这篇文章中描述的所有内容,但对我没有任何帮助。
Here is what I mean by React related suggestions and autocomplete.这就是我所说的 React 相关建议和自动完成的意思。
"*.jsx"
extension assosiacted with javascriptreact
language mode . "*.jsx"
扩展与javascriptreact
语言模式相关联。
Change the file type from javascript
to javascriptreact
, you can do it from the bottom panel.将文件类型从
javascript
更改为javascriptreact
,您可以从底部面板进行操作。
Or run Change language Mode
from command palette ( ctrl+p
).或从命令面板 (
ctrl+p
) 运行Change language Mode
。
Also, you can add files.associtiations
on your settings.json
:此外,您可以在
settings.json
上添加files.associtiations
:
"files.associations": {
"*.react.js": "javascriptreact",
"*.jsx": "javascriptreact",
"*.js": "javascriptreact",
}
I am also having same problem but when I keep index.js file open in background everything just works.我也有同样的问题,但是当我在后台保持 index.js 文件打开时,一切正常。 You can also try
你也可以试试
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.