import React, { useState } from 'react' /** * Tabs切换标签 * @param {*} param0 * @returns */ const Tabs = ({ children }) => { if (!children) { return <>> } let count = children.length children.forEach(e => { if (!e) { count-- } }) if (count === 1) { return {children} } const [currentTab, setCurrentTab] = useState(0) function tabClickHandle (i) { setCurrentTab(i) } return ( { {children.map((item, index) => { return { tabClickHandle(index) }}> {item?.key} })} {children.map((item, index) => { return {item} })} } ) } export default Tabs