新建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生效。

暂无评论