import React, {Component} from 'react'
|
import { Button } from 'antd'
|
|
/**
|
* @description 异步加载模块
|
* @param {*} importComponent
|
*/
|
export default function asyncComponent(importComponent) {
|
return class extends Component {
|
constructor(props) {
|
super(props)
|
|
this.state = {
|
component: null
|
}
|
}
|
|
async componentDidMount() {
|
const {default: component} = await importComponent()
|
|
this.setState({component})
|
}
|
|
render() {
|
const C = this.state.component
|
const btn = this.props.btn || {}
|
|
return C ?
|
<C {...this.props} /> :
|
<Button icon={btn.OpenType === 'excelOut' ? 'download' : 'upload'} disabled={true} title={btn.label} style={{border: 0, background: 'transparent'}}></Button>
|
}
|
}
|
}
|