VS代码如何将HTML组合到.js文件中



我尝试在VS代码中创建React项目。当我尝试使用如下的HTML标签保存index.js时,VS代码会打破我的标签,并在单词和括号之间推空。找不到我如何修复它……

// this is before I safe the project
ReactDOM.render( <div> Hello World! </div>, document.getElementById('root'))
// this is after I safe the project
ReactDOM.render( < div > Hello World! < /div>, document.getElementById('root'))

要么:

  1. 将所有.js文件扩展名更改为.jsx
  2. 在用户/工作区设置中添加文件关联:
"files.associations": {
    "*.js": "javascriptreact"
  }

最新更新