import {useEffect, useState} from "react"; import {Tabs, Loading} from '@nutui/nutui-react-taro' import {pageCmsArticle} from "@/api/cms/cmsArticle"; import {CmsArticle} from "@/api/cms/cmsArticle/model"; import ArticleList from "./ArticleList"; const ArticleTabs = (props: any) => { const [loading, setLoading] = useState(true) const [tab1value, setTab1value] = useState('0') const [list, setList] = useState([]) const reload = async (value) => { const {data} = props pageCmsArticle({categoryId: data[value].navigationId, page: 1, limit: 10}).then((res) => { res && setList(res?.list || []) }) .catch(err => { console.log(err) }) .finally(() => { setTab1value(value) setLoading(false) }) } useEffect(() => { reload(0).then() }, []); if (loading) { return ( 加载中 ) } return ( <> { reload(value).then() }} > {props.data?.map((item, index) => { return ( ) })} ) } export default ArticleTabs