- 博客(7)
- 收藏
- 关注
原创 解决antd中form表单包含Select下拉框默认值与下拉框中的值关联问题
问题描述:在Form表单中,下拉框多选的情况下,如果点击的是编辑按钮,会在表单中传递默认值,但是表单中的默认值和下拉框中的值没有关联,导致再次选择下拉框中的值还会再次选中<Form.Item name="color" label="color" rules={[{ required: true }]} initialValue={['白色','灰色']}> <Select allowClear
2021-09-10 16:47:03
3732
原创 解决前端传递空字符串在浏览器解析为null
使用axios发送get请求,后端有一个参数接收空字符串,需要转换成JSON格式在浏览器中才能显示空字符串,否则传递的为nullaxios({ url,//请求路径 method:"GET",//get请求 params:{ sys:JSON.stringify("") }})...
2021-08-04 15:24:48
2196
原创 ant design Tree选中一个子节点父节点也被选中
Tree组件中onCheck方法的第二个参数有halfCheckedKeys属性,此属性中保存父节点的keyfunction onCheck(checkedKeys,info) { let allCheckedKeys = checkedKeys.concat(info.halfCheckedKeys);//将父节点拼接到子节点}return ( <Tree onCheck={onCheck} />)...
2021-08-03 17:58:31
4152
2
原创 useContext实现组件间的通信
1.父组件中创建myContext对象,myContext对象返回一个Provider React组件,接收value属性传递给子组件import { createContext, useState } from 'react';export const myContext = createContext(null);//初始值为nullconst Parent = () => { const [count,setCount] = useState(0); retu
2021-08-02 09:45:08
404
原创 useReducer接收异步请求的数据
const init = { dataList:[] };//初始化dataStateconst [state,dispatch] = useReducer(reducer,init);useEffect(() => { //发送网络请求 axios.get("/user?ID=123").then(res => { dispatch({ type:ACTION_TYPE.GETDATA, payload:.
2021-07-23 15:58:53
1052
原创 解决Each child in a list should have a unique “key“ prop.
1.表格报错表格数据需要在dataSource数组中添加key,如果从后端接收的数据中没有key,在Table属性中添加rowKey,确保record.id是唯一的即可const data = //后端返回的数据const columns = [{ title: '用户名', dataIndex: 'username', key: 'username', }, { title: '手机号', dataIndex: 'mo
2021-07-22 15:21:42
1374
原创 ant design弹出框获取表单数据
1.Modal弹出框获取表单数据const form = React.createRef();const submit = () => { form.current.submit();}const onReset = () => { form.current.resetFields();};<Modal visible={visible} onCancel={onCancel} footer={[<Button type="primary" onC
2021-07-21 15:56:32
2380
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人