简体   繁体   English

在VSCode中,如何通过IntelliSense导入React?

[英]In VSCode, how to import React through IntelliSense?

In the image below, if I press Enter nothing happens. 在下图中,如果按Enter键 ,则不会发生任何事情。

I was expecting IntelliSense to add import React from 'react'; 我期待IntelliSense import React from 'react';添加import React from 'react'; to the top of the file. 到文件顶部。

在此处输入图片说明

I think your best shot should be using snippets. 我认为您最好的选择是片段。 You can either create one for yourself (here's the official VSCode snippets documentation ), or you could use an existing snippets extension (like this one). 您可以自己创建一个(这是VSCode的官方摘录文档 ),也可以使用现有的摘录扩展名( 如此 )。

I Believe a snippet you could use would look something like so: 我相信您可以使用的摘要如下所示:

{
  "Import React": {
    "prefix": ["React"],
    "body": ["import React from \"react\";"],
    "description": "Importing React"
  }
}

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

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