react项目遇到的问题及解决方案【持续更新中...】

1、modalForm表单每次点开显示的重复

这个问题可能是你没有给模态框加一个随机的key
如果加上key之后每次点击出来的模态框就是一个新的和上次无关

2、树形选择数据结构

const cascaderOptions = [
  {
    label: '综合管理中心',
    value: 'fe',
    children: [
      {label: '运营部',value: 'js'}, {label: '技术部',value: 'ts'},
    ],
  },
];

3、select下拉框

	const statusList = [{label:'无效',value:'0'},{label:'有效',value:'1'}];
	{
      title: '状态',
      dataIndex: 'status',
      fieldProps: { options: statusList},
      valueType: 'select',
        render: (_, record) => [
        <Tag color={record.value == 1 ? 'blue' : 'magenta'} key="subscribeAlert">
          {statusList[record.value]}
        </Tag>,
      ],
    },

4、表单横向

 <ProForm layout="horizontal">

可能遇到的失效原因:ProForm大小写拼写错误、Form表单进行了嵌套

5、下拉框默认值

initialValue={userInfo?.parentIds?.slice(3,userInfo?.parentIds.length-1)?userInfo?.parentIds?.slice(3,userInfo?.parentIds.length-1)?.split('/')?.map(Number):''}

6、preview提示开开浏览器js权限:请求接口路径问题,看看接口路径拼对了没

在这里插入图片描述

7.未知报错 删掉umi文件重启

mf-va_remoteEntry.js:717 Uncaught (in promise) Error: Module “./D:/desktop/gitee/dayun-antd-react/node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/objectSpread2” does not exist in container.
while loading “./D:/desktop/gitee/dayun-antd-react/node_modules/@umijs/babel-preset-umi/node_modules/@babel/runtime/helpers/esm/objectSpread2” from webpack/container/reference/mf
在这里插入图片描述

8、react中将数据存放在缓存中的方法和将数据从缓存中取出的方法

localStorage.setItem('user',values.username);

localStorage.getItem('user');

9、左侧菜单不展示某个页面

hideInMenu:true

10、Ref

actionRef.current.reload();  //刷新

formRef.current.getFieldsValue(true) //获取formRef的value

formRef.current?.setFieldsValue(info) //把info赋值给formRef

formRef.current?.validateFieldsReturnFormatValue?.() .then((values) => {
        //校验完毕并返回values
      })
      .catch((errorInfo) => {
        message.error('请将表单填写完整', 2.5);
      });

11、element.nodeName.toLowerCase is not a function

有节点命名成了nodeName,这会有冲突,改个名字就好了

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值