【发布时间】:2018-08-03 07:11:27
【问题描述】:
我在使用 brunch build 构建 React 组件时出错。 这个错误是关于什么的?
error: Compiling of js/assets/jss/material-dashboard-pro-react/views/userProfileStyles.jsx failed. L5:4 js/assets/jss/material-dashboard-pro-react/views/userProfileStyles.jsx: Unexpected token
3 | cardTitle,
4 | cardIconTitle: {
> 5 | ...cardTitle,
| ^
6 | marginTop: "15px",
7 | marginBottom: "0px",
8 | "& small": {
也出现了这个错误
14:44:44 - error: Compiling of js/components/Accordion/Accordion.jsx failed. L22:15 Unexpected token
20 | };
21 | }
> 22 | handleChange = panel => (event, expanded) => {
| ^
23 | this.setState({
24 | active: expanded ? panel : -1
25 | });
【问题讨论】:
-
这称为扩展语法,您很可能需要将babel-brunch 与stage 3 预设一起使用才能使用它。
-
@Tholle 感谢您的回答。我使用 npm install 安装和配置。像这样
plugins: { babel: { presets: ["es2015", "react", "env", "stage-3"], // Do not use ES6 compiler in vendor code ignore: [/vendor/] } },但我遇到了错误 -
不客气!很好,传播语法现在似乎正在工作。您现在收到类属性错误,即stage 2 proposal。试试
"stage-2"而不是"stage-3"。
标签: javascript reactjs brunch