Visual Studio代码更改格式(React-JSX) [英] Visual studio code changes format (React-JSX)
问题描述
我的index.js中有以下代码段
I've the following snippet in my index.js
class App extends Component {
render() {
return ( <div style = { styles.app } >
Welcome to React!
</div>
)
}
}
该代码有效,但是每次我保存(ctrl + s)visual studio格式的jsx时都这样:
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>
)
}
}
我该如何解决?谢谢
推荐答案
最后,技巧是将底部工具栏上的文件格式从JavaScript更改为JavaScript React. 由于没有找到有关此主题的任何文档,因此我将其发布在这里以供将来参考.
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.
除上述内容外.如果点击为.js配置文件关联",则可以将所有.js文件设置为Javascript React
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屋!