Category - Ant-Design-React

2023-06-08 01:43:46    15    0    0
  1. 图片地址没带任何图片标识(如.png或者http://xxx?id=11)后缀
  2. 刚刚上传的图片回显不出来
    上传图片后图片的status属性一直是uploading状态,图片上传成功,却一直是进度条状态。
    解决方法是在 onCancel={this.handleCancel}回调方法开头加setFileList([…data.fileList]);
  3. 其他官网未显示可用配置
    可配置 onSuccess={e => onSuccess(e)}获取请求返回结果
2023-03-06 18:48:29    9    0    0

父节点如果有回显的情况下

1.循环遍历出最深层子节点,存放在一个数组中
2.将后台返回的含有父节点的数组和第一步骤遍历的数组做比较
3.如果有相同值,将相同值取出来,push到一个新数组中
4.利用这个新的重组的数组给Tree组件selected赋值

  1. const deepArr = [] //deepArr存放所有子节点的数组
  2. //第一步骤:子节点放在一个数组中
  3. const requestList = (data) => {
  4. data && data.map(item => {
  5. if (item.children && item.children.length > 0) {
  6. requestList(item.children)
  7. } else {
  8. deepArr.push(item.id)
  9. }
  10. return null
  11. })
  12. return deepArr
  13. }
  14. //第2,3步骤的方法
  15. const uniqueTree = (uniqueArr, Arr) => {
  16. let uniqueChild = []
  17. for (var i in Arr) {
  18. for (var k in uniqueArr) {
  19. if (uniqueArr[k] === Arr[i]) {
  20. uniqueChild.push(uniqueArr[k])
  21. }
  22. }
  23. }
  24. return uniqueChild
  25. }
  26. //调用第2,3步骤的方法
  27. const getRoleInfo = () => {
  28. getData({ id: Id }).then(res => {
  29. const ids = res.data
  30. const uniqueChild = this.uniqueTree(ids, deepArr)
  31. setCheckedKeys(uniqueChild)
  32. })
  33. }
  34. <Tree
  35. checkable
  36. checkedKeys={checkedKeys}
  37. defaultExpandedKeys={checkedKeys}
  38. fieldNames={{
2019-11-14 07:46:48    45    0    0
## 勾选 ``` import React,{ Component } from 'react'; import { Table,Icon,Divider } from 'antd'; let data = [{ key: 1, name: '花骨朵', age: 18, hobby: '看书', },{ key: 2, name: '天下',
2019-11-14 07:46:48    24    0    0
### antd最新版可以使用next(), prev(), goTo() ### antd旧版使用refs.slick.slickNext(), refs.slick.slickPrev(), refs.slick.slickGoTo() next = ()=> { this.carouselRef.refs.slick.slickNext(); } p
2019-11-14 07:46:48    16    0    0
### 高度样式 this.setState({ showInfoDetail: false, protocolInfo: null })} footer={[ , ]} >
2019-11-14 07:46:48    7    0    0
> https://ant.design/docs/react/recommendation-cn
2019-11-14 07:46:48    6    0    0

只能选今天或者今天以后的日期

  1. disabledDate = (current) => {
  2. return current && current < moment().startOf('day').subtract(0, 'days');
  3. }

只能选今天或者今天以后的小时

  1. disabledRangeTime = (_, type) => {
  2. const { form: { getFieldValue } } = this.props
  3. if (type === 'start') {
  4. const nowHours = moment().hours()
  5. const time = getFieldValue("time")
  6. if (time && moment(time[0].format("YYYY-MM-DD")).valueOf() <= moment(moment().format("YYYY-MM-DD")).valueOf()) {
  7. return {
  8. disabledHours: () => this.range(0, nowHours),
  9. };
  10. }
  11. }
  12. }

在关闭选择时间面板的时候判断是否小于(当前时间 + 10s)

  1. onOpenChange = (status) => {
  2. const { form: { getFieldValue, setFields } } = this.props
  3. const time = getFieldValue("time")
  4. if (!status) {
  5. if (time && (moment(time[0]).valueOf() + 10000) < moment().valueOf()) {
  6. setFields({
  7. time: {
  8. value: null,
  9. errors: [n