【求助】使用father打包,封装antd组件报错
打包报错信息如下: Can't import the named export 'Radio' from non EcmaScript module (only default export is available)
封装组件代码如下: import React from 'react'; import { Radio } from 'antd';
const RadioGroup = Radio.Group;
export default class SmartRadio extends React.Component {
constructor(props) { super(props); console.log('%o', props);
this.state = {
value: props.value,
};
// this.onChange = this.onChange.bind(this);
}
onChange =(e) => { console.log('radio checked', e.target.value); this.setState({ value: e.target.value, }, ()=> { const {value} = this.state; this.props.onChange(value); }); }
render() { return ( <RadioGroup onChange={(e) => this.onChange} value={this.state.value}> {this.props.data ? this.props.data.map(d => ( <Radio value={d.value}>{d.text}</Radio> )) : ''} </RadioGroup> ); } }
请问如何解决
使用umi dev 验证产物时,报了上面这个错 Can't import the named export 'Radio' from non EcmaScript module (only default export is available)
father 4 已发布,可尝试升级到最新版:https://github.com/umijs/father/blob/master/docs/guide/migrate.md
旧版本不再维护,感谢支持