新建tsx文件编写布局代码时报错
Cannot use JSX unless the '--jsx' flag is provided
错误发生在下面代码的div
上,是因为tsconfig.json
里没有添加jsx的配置。
import React from 'react'
export default class demo extends React.Component {
render() {
return (
<div>
Hello
</div>
);
}
}
解决办法:
在tsconfig.json
中加入:
"jsx": "react",
如果保存之后仍然报错,需重启VSCode生效。
暂无评论