当进入到index.html,在进行页面初始化之后,就需要请求轮播图数据进行轮播图的显示。
<script type="text/javascript">
var baseUrl="http://localhost:8080/";
var vm = new Vue({
el:"#container",
data:{
username:"",
userimg:"",
isLogin:false,
indexImgs:[]
},
created(){
//从cookie中获取token username userImg
var token = getCookieValue("token");
if(token != null && token != ""){
this.isLogin = true;
this.username = getCookieValue("username");
this.userimg = getCookieValue("userimg");
}
//请求轮播图数据
var url = baseUrl + "/index/indeximg";
axios.get(url).then((res)=>{
var vo = res.data;
this.indexImgs = vo.data;
//渲染轮播图
//初始化轮播图动画效果
setTimeout(function(){
$('.am-slider').flexslider();
},100);
});
}
});
</script>