StandardJS和React类导出Unexpected token =

问题描述 投票:0回答:1

有人能说清楚我从StandardJS回来的通知吗?

解析错误:意外的令牌=

代码如下:

export default class foreignDataFormat extends _base {
    static input = class ForeignDataFormatInput extends React.Component {
        render () {

        }
    }
}

错误是指第二行input = class

reactjs standardjs
1个回答
0
投票

在JavaScript中,类不能定义为静态。但方法可以定义为静态。你只需定义(也可能意味着定义)类,如:

export default class foreignDataFormat extends _base {
    const input = class ForeignDataFormatInput extends React.Component {
        static myMethod() { 
          //... my static method
        }
        render () {

        }
    }
}

您可能有兴趣看到this post

© www.soinside.com 2019 - 2024. All rights reserved.