Visual Studio 代码更改格式(React-JSX) [英] Visual studio code changes format (React-JSX)
问题描述
我的 index.js 中有以下代码片段
class App 扩展组件 {使成为() {return ( <div style = {styles.app } >欢迎来到反应!
)}}
代码有效,但每次我保存(ctrl+s)visual studio 时都会像这样格式化 jsx:
class App 扩展组件 {使成为() {return ( < div style = {styles.app } >欢迎来到反应!</div>)}}
我该如何解决这个问题?谢谢
最后的诀窍是将底部工具栏上的文件格式从 JavaScript 更改为 JavaScript React.我在这里发布它以备将来参考,因为我没有找到关于这个主题的任何文档.
除上述之外.如果单击为 .js 配置文件关联",则可以将所有 .js 文件设置为 Javascript React
I've the following snippet in my index.js
class App extends Component {
render() {
return ( <div style = { styles.app } >
Welcome to React!
</div>
)
}
}
The code works, but every time I save (ctrl+s) visual studio format the jsx like that:
class App extends Component {
render() {
return ( < div style = { styles.app } >
Welcome to React!
<
/div>
)
}
}
How can I solve this? thanks
In the end what did the trick was changing the file format from JavaScript to JavaScript React on the bottom toolbar. I'm publishing it here for future reference since I didn't find any documentation on this topic.
In addition to the above. If you click 'Configure File Association for .js' you can set all .js files to Javascript React
这篇关于Visual Studio 代码更改格式(React-JSX)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!