所以我刚刚尝试获取谷歌 Material 对话框。 我对 meteor 和 react 非常陌生,所以答案对你来说可能比对我来说更明显。
即便如此,我的控制台还是给了我这个错误:
Missing class properties
transform.
此文件第 16 行:
export default class DialogExampleCustomWidth extends React.Component {
state = {
open: false,
};
handleOpen = () => {
this.setState({open: true});
};
handleClose = () => {
this.setState({open: false});
};
render() {
const actions = [
<FlatButton
label="Cancel"
primary={true}
onTouchTap={this.handleClose}
/>,
<FlatButton
label="Submit"
primary={true}
onTouchTap={this.handleClose}
/>,
];
return (
<div>
<RaisedButton label="Dialog With Custom Width" onTouchTap={this.handleOpen} />
<Dialog
title="Dialog With Custom Width"
actions={actions}
modal={true}
contentStyle={customContentStyle}
open={this.state.open}
>
This dialog spans the entire width of the screen.
</Dialog>
</div>
);
}
}
错误出现在state = {
我读过多篇文章,但似乎无法理解。感谢您的帮助和时间
最佳答案
Meteor 默认情况下不支持箭头函数,但今天您可以简单地更改它:
meteor npm install --save-dev babel-plugin-transform-class-properties
在项目中编辑 package.json 并添加以下内容以使 the package work:
"babel": {
"plugins": ["transform-class-properties"]
}
关于reactjs - 缺少类属性转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40271289/