now there is a category information that needs to be looped out.
needs to traverse the entire catalog tree starting from the root catalog. That is, first pass 0 to get all the first-level categories ID, then get all the second-level categories by traversing the first-level category ID, and finally get the third-level categories by traversing the second-level category ID. I wrote the following. When I get the first-level directory, I don"t know how to write it. I don"t know if it is written correctly
//
querycategory=()=>{
window.bridge.call("open.api.request", {
version: "1",
namespace: "com.alibaba.product",
name: "alibaba.category.get",
data: {
categoryID:this.state.categoryID, // categoryID=0
webSite:"1688"
}
}, (res) => {
{/* */}
const categoryList=res.result.data.categoryInfo[0].childCategorys;
this.setState({
categoryData:categoryList
} )
});
}
//
categorylist=()=>{
const list=this.state.categoryData;
const lists=list.length
?
list.map((newlist,index)=>(
//
<TreeNode label={newlist.name} key={newlist.id}>
{/* iDquerycategory */}
<TreeNode label="" key="0">
</TreeNode>
</TreeNode>
))
:""
;
return lists;
}
I just learned React. I don"t know how to do it. Ask for advice!