# 📆 2021.12.01

# 问题一:

  1. 问题描述:在 antd pro v5 项目中管理代码,使用 gitlab 上传代码,到 git commit 步骤报错
stylelint --syntax less found some errors. Please fix them and try committing again
npm run lint-staged:js found some errors. Please fix them and try committing again

1
2
3
  1. 原因:在使用 antd pro v5 创建项目时候,开启 eslint 的检测机制,所以如果提交的代码不符合检测机制,上传失败

  2. 解决:

  • 解决一:在git commit时,加上--no-verify跳过检测机制,例如
git commit --no-verify -m'you git message'
1
  • 解决二:到根目录中的.eslintignore 文件,将 src 放入其中,以便 git 提交时跳过 src 目录中所有文件的 eslint 检测机制。如下
/lambda/
/scripts
/config
.history
public
dist
.umi
mock
src  (将 src 放入这里)
1
2
3
4
5
6
7
8
9

# 问题二:

  1. 问题描述:在父组件中有个 header 子组件,在 header 子组件中有个 modal,想实现如果没有选择数据或者选了多条数据,是不能弹出 modal,因为取消 modal 操作在 header 子组件中,所以,就需要在父组件中去调用子组件中的函数
  2. 方法:
  • 方法一:ref

  • 方法二:

import ChildCmpt from "./ChildCmpt";
class FatherCmpt extends React.Component {
    fnc=()=>{
 // 父组件调用子组件的handleMdfModal方法
      this.ChildCmpt.current.childFunc();
    }
    render(){
        ...
    }
}
export default FatherCmpt;
1
2
3
4
5
6
7
8
9
10
11

# 问题三

  1. 问题描述:在向后端请求数据的时候,出现以下的报错,其大概意思就是出现跨域问题。
  2. 原因:后端已实现跨域,所以问题可能在前端的配置这里
  3. 解决: 方法一:找到将/utils/request 文件,注释掉 credentials 方法二:不用 antd pro 封装的,直接用 fetch
fetch("你的url请求地址")
  .then((res) => {
    console.log("res", res.json());
  })
  .catch();
1
2
3
4
5

# 📆 2021.12.10

# 问题一

  1. 问题描述:<InputNumber> 交互 bug,输入了错误值,然后直接确认,给人错觉的,以为是错误值也保存成功了。
  2. 解决:改用<Input />

# 📆 2021.12.31

  1. 问题描述:想使用 antd pro 组件EditableProTable,在引入后出现类似报错antd "./antd/es/xxx/style" does not exist in container.

  2. 解决:这是mfsu引起的问题,删掉src/.umi文件夹即可。