123
>: pip install django-cors-headers插件参考地址:https://github.com/ottoyiu/django-cors-headers/
123456789101112131415161718192021222324252627282930
# 注册appINSTALLED_APPS = [ ...'corsheaders',]# 添加中间件MIDDLEWARE = [ ...
'django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware',]# 允许跨域源CORS_ORIGIN_ALLOW_ALL = True# 允许的请求头CORS_ALLOW_HEADERS = ("accept","accept-encoding","authorization","content-type","dnt","origin","user-agent","x-csrftoken","x-requested-with",# 额外允许的请求头'token',)
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
<template> <div class="banner"> <el-carousel height="400px"> <el-carousel-item v-for="banner in banner_list" :key="item"> <router-link :to="banner.link"> <img :src="banner.image" alt=""> </router-link> </el-carousel-item> </el-carousel> </div></template><script> export default { name: "Banner", data() { return { banner_list: [] } }, created () { this.$axios.get('http://127.0.0.1:8000/home/banners/').then(response => { console.log(response.data); this.banner_list = response.data.msg; }).catch(error => { console.log(">>>", error); }) } }</script><style scoped> .el-carousel__item { height: 400px; min-width: 1200px; } .el-carousel__item img { height: 400px; margin-left: calc(50% - 1920px / 2); }</style>
posted on 2020-12-06 17:48 Plyc 阅读(89) 评论(0) 编辑 收藏 举报