简体   繁体   English

自动将标签添加到VSCode中的React组件

[英]Auto-adding tags to React Components in VSCode

I'm doing some work in React, and want to be able to auto-expand my custom components so that I don't have to keep manually adding < , /> and > . 我在React做了一些工作,并希望能够自动扩展我的自定义组件,这样我就不必手动添加</>>

Since Emmet already expands traditional markup ( div , h1 , etc.) I was wondering if I could expand my own components with some plugin/setting. 由于Emmet已经扩展了传统标记( divh1等),我想知道是否可以使用一些插件/设置扩展自己的组件。 The | | character represents my cursor. character代表我的光标。

How it works right now 它现在如何工作

import Items from '../components/Items'

...
render() {
  return (
    <div>
     Ite| [Suggestions: Item] 
    </div>
  )
}
...

I see the suggestion, press [Tab], and it expands to this 我看到了这个建议,按[Tab],它会扩展到此

<div>
  Items|
</div>

What I'm looking for 我正在寻找什么

<div>
  <Items>|</Items>
</div>

Is there an extension or setting that I need to toggle somewhere to achieve this? 是否有扩展或设置我需要在某处切换以实现此目的?


EDIT 编辑

Okay after some more working with react, I've found that Emmet will expand certain words but not others? 好吧,经过一些更多的反应,我发现Emmet会扩展某些词而不是其他词? Are my component names just edge cases or am I missing something? 我的组件名称只是边缘情况还是我错过了什么?

工作Emmet扩展 Emmet扩展无法正常工作

Use Auto Close Tag extension. 使用自动关闭标记扩展名。 It immediately adds the closing tag when you type in the opening tag in front. 当您在前面输入开始标记时,它会立即添加结束标记。

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

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