React 根据 组件名称动态加载组件
const Component = ({ is, children, ...restProps }) => { const Tag = require("antd")[is]; if (!Tag) return false; return <Tag {...restProps}>{children}</Tag>; }; export default Component;
<Component is="Switch" checkedChildren="开启" unCheckedChildren="关闭" defaultChecked onClick={() => console.log(222)} > 122 </Component>