reactjs - 缺少类属性转换

标签 reactjs meteor

所以我刚刚尝试获取谷歌 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 默认情况下不支持箭头函数,但今天您可以简单地更改它:

add the following package:

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/

相关文章:

javascript - ReactJS - TypeError : requests. map 不是函数

meteor - 将 Meteor.js 内置 Google 身份验证限制为域

javascript - Meteor collection.insert 回调返回新的id

javascript - 应用程序使用什么 API 来访问(发送金额)比特币钱包

javascript - Meteor 和 Phaser - 简单示例的错误

javascript - 设置 Meteor、Vue 和 Typescript

php - Laravel PATCH 请求不读取 Axios 表单数据

javascript - Ref 获取子元素

javascript - 如何使用按钮和 redux 隐藏/显示单独的表单?

reactjs - Typescript React TS2307 找不到模块 json