ant design + react带有二级导航菜单自动生成

最近在项目中面临导航特别多的情况,需要将导航存到数据库里面,然后前端从接口那数据渲染生成。antd-admin里面有个案例,但是太过复杂,于是自己开始简化写

1、数据格式:

2、在sidebar 渲染数据:

 

 3、在route里面找到对应的路径即可

 

转载于:https://www.cnblogs.com/ryt103114/p/7060887.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Ant Design Pro React 提供了 Upload 组件来实现上传功能。以下是实现上传的步骤: 1. 导入 Upload 组件和其他必要的组件: ``` import { Upload, message } from 'antd'; import { InboxOutlined } from '@ant-design/icons'; ``` 2. 定义上传组件的属性和状态: ``` const { Dragger } = Upload; const props = { name: 'file', multiple: true, action: 'https://www.mocky.io/v2/5cc8019d300000980a055e76', onChange(info) { const { status } = info.file; if (status !== 'uploading') { console.log(info.file, info.fileList); } if (status === 'done') { message.success(`${info.file.name} file uploaded successfully.`); } else if (status === 'error') { message.error(`${info.file.name} file upload failed.`); } }, }; class UploadComponent extends React.Component { state = { fileList: [], }; handleChange = ({ fileList }) => this.setState({ fileList }); render() { const { fileList } = this.state; return ( <Dragger {...props} fileList={fileList} onChange={this.handleChange}> <p className="ant-upload-drag-icon"> <InboxOutlined /> </p> <p className="ant-upload-text">Click or drag file to this area to upload</p> <p className="ant-upload-hint"> Support for a single or bulk upload. Strictly prohibit from uploading company data or other band files </p> </Dragger> ); } } ``` 3. 在 render() 方法中渲染上传组件: ``` render() { return ( <div> <UploadComponent /> </div> ); } ``` 这样就可以实现一个基本的上传组件。此外,Ant Design Pro React 还提供了其他的上传组件和功能,可根据具体的需求进行选择和使用。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值