1:添加第三方插件
yarn add babel-plugin-transform-decorators-legacy --dev
yarn add @babel/plugin-proposal-decorators --dev
2:package.json未添加配置
"babel": {
"plugins":[
["@babel/plugin-proposal-decorators", {"legacy":true}],
["@babel/plugin-proposal-class-properties", {"loose":true}]
]
}
3:TS中使用
interface IProps {
popupBottom?: any;
setPopupBottom?: (result: boolean) => void;
}
@(connect(
(state: any) => ({popupBottom: state.popupBottom}),
(dispatch) => ({
setPopupBottom: bindActionCreators(actions.actPopupBottomShow, dispatch),
}),
) as any)
export default class xxx extends Component<IProps>{
}