千峰商城-springboot项目搭建-58-轮播图前端功能实现

当进入到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>

 

 

 

 
posted @ 2022-07-18 11:29  临易  阅读(147)  评论(0编辑  收藏  举报