尝试为基于反应的项目设置文档。
使用来自“create-react-app”的新“my-app”和一个非常幼稚的 *.js 文件,我得到一个错误:
C:\xampp\htdocs\my-app2\node_modules\react-styleguidist\bin\styleguidist.js
You can now view your style guide in the browser:
Local: http://localhost:6060/
On your network: http://10.100.11.165:6060/
FAIL Failed to compile
./src/src/topnav/topnav.js
SyntaxError: C:\xampp\htdocs\my-app2\src\src\topnav\topnav.js: Support for the experimental syntax 'classProperties' isn't currently enabled (8:20):
6 | */
7 | export default class Button extends React.Component {
> 8 | static propTypes = {
| ^
9 | /** Description of prop "foo". */
10 | foo: PropTypes.number,
11 | /** Description of prop "baz". */
Add @babel/plugin-proposal-class-properties (https://git.io/vb4SL) to the 'plugins' section of your Babel config to enable transformation.
@ ./node_modules/react-styleguidist/lib/index.js (./node_modules/react-styleguidist/loaders/styleguide-loader.js!./node_modules/react-styleguidist/lib/index.js) 46:30-89
@ ./node_modules/react-styleguidist/lib/index.js
@ multi ./node_modules/react-styleguidist/lib/index ./node_modules/react-styleguidist/node_modules/react-dev-utils/webpackHotDevClient.js
有谁熟悉这个错误?
我怀疑修复与 Babel 有某种关系,但是,我无法从以前的查询中解决它。