react

react 遍历

1
2
3
4
5
6
res.data.map(
(item, index)=>{
item.key = index;
return item;
}
);

antd table

1
2
3
const columns
const dataSource
const rowSelection

CROS

1
Access to XMLHttpRequest at 'http://127.0.0.1:8000/api/imooc/order/' from origin 'http://127.0.0.1:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
1
Origin: http://127.0.0.1:3000
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
pip install django djangorestframework django-cors-headers

INSTALLED_APPS = [
...
'corsheaders',
...
]

MIDDLEWARE = [
...
'corsheaders.middleware.CorsMiddleware'
]


CORS_ORIGIN_ALLOW_ALL=True

CORS_ORIGIN_WHITELIST = [
'google.com',
'hostname.example.com',
'localhost:8000',
'127.0.0.1:9000'
]

index.js:1375 Warning: Failed prop type: Invalid prop id of type array supplied to Select, expected string.

expected to return a value in arrow function array-callback-return

A map() creates an array, so a return is expected for all code paths (if/elses).

If you don’t want an array or to return data, use forEach instead.

坚持原创技术分享,您的支持将鼓励我继续创作!