安装django-cors-headers
python -m pip install django-cors-headers
在#setting.py 下添加如下代码
INSTALLED_APPS = [ ..., "corsheaders", ..., ] MIDDLEWARE = [ ..., "corsheaders.middleware.CorsMiddleware", #尽量放在最上面 "django.middleware.common.CommonMiddleware", ..., ] ... CORS_ORIGIN_ALLOW_ALL = True # 新增这一句