我在index.js中有以下代码段
class App extends Component {
render() {
return ( <div style = { styles.app } >
Welcome to React!
</div>
)
}
Run Code Online (Sandbox Code Playgroud)
}
代码工作,但每次我保存(Ctrl + S)的Visual Studio格式的JSX这样的:
class App extends Component {
render() {
return ( < div style = { styles.app } >
Welcome to React!
<
/div>
)
}
Run Code Online (Sandbox Code Playgroud)
}
我怎么解决这个问题?谢谢
我不知道这是否是VS Code的默认行为,(我在默认情况下有很多自定义配置)
但是当我格式化代码时,它会转换这样的代码:
const simpleInput = (
<Input
{...input}
{...others}
state={state}
/>
);
Run Code Online (Sandbox Code Playgroud)
进入:
const simpleInput = (
<Input
{...input}
{...others}
state={state}
/> <- Here is the difference
);
Run Code Online (Sandbox Code Playgroud)
我的es-lint会发出警告 [eslint] The closing bracket must be aligned with the line containing the opening tag (expected column 5) (react/jsx-closing-bracket-location)
如何调整它以使其与标签开始正确对齐?
注意,除了该文件被使用JSX在.js文件中,我配置VS代码相应.