How to comment jsx code out in .js files in VSCode

2019-01-31 11:07发布

Unlike in webstorm, I'm unable to comment jsx code out in .js files in Visual Studio Code.

10条回答
放我归山
2楼-- · 2019-01-31 11:34

This also works

{
  //this.props.user.profileImage
  //? <img
  //    src={ this.props.user.profileImage }!
  //    alt=""
  //  />
  //: <FontAwesome name='smile-o' />
}
查看更多
对你真心纯属浪费
3楼-- · 2019-01-31 11:34

Currently in Visual studio code it could be done by pressing combination - Shift+Alt+A and comment "jsx" code it produces - {/**/} comments.

查看更多
贪生不怕死
4楼-- · 2019-01-31 11:40

In Visual Studio code Hit Cmd + / if you are running on mac or place

{/* Your Code */}

Thank you.

查看更多
我欲成王,谁敢阻挡
5楼-- · 2019-01-31 11:42

Try to disable all plugins, because they can change editor's behaviour. For example if use Babel ES6/ES7 plugin, editor comments .jsx syntax by // instead of {/*. You see see the issue here.

查看更多
forever°为你锁心
6楼-- · 2019-01-31 11:42

{/* this works, but only single line */}

查看更多
该账号已被封号
7楼-- · 2019-01-31 11:43

You can comment out JSX by {/**/}

Example :

render() {
  return (
    <div>
      <Component1 />
      {/* <Component2 /> */}
    </div>
  )
}

and then Component2 would be commented out

查看更多
登录 后发表回答