鍍金池/ 問答/HTML/ react中‘Missing class properties transfor

react中‘Missing class properties transform’問題

clipboard.png

在react+es6項目中,下面的代碼就會報上面圖片的問題,還請高手指點:

class PaymentContainer extends BaseListContainer {

static propTypes = {
    rowData: PropTypes.any,//
    rowID: PropTypes.string,
    paddingTop: PropTypes.number,
    callback: PropTypes.func,
    isShowMerchantName: PropTypes.bool
};

static defaultProps = {
    callback: () => {

    },
    isShowMerchantName: true

};

}

class PaymentContainer extends BaseListContainer {

renderSuccess = (confirmInfo) => {
    return (
        <PaymentHeaderCell confirmInfo={confirmInfo} timeoutCallback={this.timeoutCallback}/>
    )
}

}

這兩種寫法都會出現(xiàn)圖片上:Module build failed: SyntaxError: Missing class properties transform.的錯

package中相應的配置(相應的一部分):{

"autoprefixer": "7.1.0",
    "babel-cli": "^6.26.0",
    "babel-core": "6.24.1",
    "babel-eslint": "7.2.3",
    "babel-jest": "20.0.3",
    "babel-loader": "^7.1.2",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "babel-preset-react-app": "^3.0.0",
    "babel-preset-stage-0": "^6.24.1",
    "babel-preset-stage-1": "^6.16.0",
    "babel-preset-stage-2": "^6.18.0",
    "babel-preset-stage-3": "^6.17.0",

}

.babelrc文件:

{
  "presets": [
  "es2015",
  "react",
  "stage-0"
],
    "plugins": []
}

請問這個問題怎么解決????

回答
編輯回答
來守候

1.
npm i babel-plugin-transform-class-properties --save-dev
2.
.babe.rc中添加插件
"plugins":["transform-class-properties"]

2018年7月1日 01:05
編輯回答
好難瘦

異常出自BaseImage.js,你貼的代碼對不上呀。
而且是語法錯誤,應該不難排查。

2017年7月4日 06:46