简单组件
import React from "react";
import { Button } from "antd";
const DsButton = ({ children, ...res }) => {children};
export default DsButton;
使用
import DsButton from "./components/Button";
Button111
嵌套组件Tabs
import { Tabs } from 'antd';
const { TabPane } = Tabs;
function callback(key) {
console.log(key);
}
const Demo = () => (
Content of Tab Pane 1
Content of Tab Pane 2
);
ReactDOM.render(, mountNode);
import React from "react";
import { Tabs } from "antd";
const { TabPane } = Tabs;
const DsTabs = (props) => {
const { children, ...res } = props;
console.log("children", props, children);
return (
{children.map((v, k) => {
const { children, title, ...res } = v.props;
if (v.type === "panel")
return (
//必须有key, callback(key)
{children}
);
})}
);
};
export default DsTabs;
使用
import DsTabs from "./components/DsTabs";
Content of Tab Pane 1
Button111
Content of Tab Pane 2
props