• 上一个问题的解决方式1


    在这里插入图片描述

    	    <script type="text/javascript">
    			var baseUrl = "http://localhost:8080/";
    			var vm = new Vue({
    				el: "#container",
    				data: {
    					username: "", // 默认为空
    					userimg: "",
    					isLogin: false,
    					indexImgs: [],
    					categories: []
    				},
    				created: function () {
    					//  从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;
    						var imgs = vo.data;
    						console.log(imgs);
    						this.indexImgs = vo.data; // vo中的 data, 才表示 轮播图中的数据
    						// 渲染 轮播图; 现在使用的是 Vue做 数据渲染; 渲染的目标简单, 在data中
    						// 加延时
    						setTimeout(function () {
    							// 初始化 轮播图 动画效果; 当把 图片是 设置到 data中, 图片就渲染到 页面中了
    							$('.am-slider').flexslider();
    						}, 100);
    					});
    					// 分类列表; 这里就拿到数据了
    					var url2 = baseUrl + "index/category-list";
    					axios.get(url2).then((res)=> {
    						console.log(res.data.data); // data 代表 resultVO;第2个data, 是我们封装的data
    						this.categories = res.data.data;
    						// 初始化 分类列表的 动画效果
    						setTimeout(function () {
    							$("li").hover(function () {
    								$(".category-content .category-list li.first .menu-in").css("display", "none");
    								$(".category-content .category-list li.first").removeClass("hover");
    								$(this).addClass("hover");
    								$(this).children("div.menu-in").css("display", "block");
    							}, function () {
    								$(this).removeClass("hover");
    								$(this).children("div.menu-in").css("display", "none");
    							});
    						}, 100);
    					});
    				}
    			});
    		script>
    		```
    		
    		让其在 数据加载完成之后, 再显示 vue中 绑定的 data
    		
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
  • 相关阅读:
    SpringBoot整合RocketMq
    Hudi 数据湖的插入,更新,查询,分析操作示例
    C语言数组和指针笔试题(四)(一定要看)
    c++中httplib使用
    Linux 文件创建、查看
    C语言实战项目---贪吃蛇(上)
    PyQt5快速开发与实战 7.1 信号与槽介绍
    2022眼康品牌加盟展,北京视力保健展,中国眼科医学技术峰会
    Spring Boot文档阅读笔记-3 Ways to Add Custom Header in Spring SOAP Request
    Redis的五大数据类型的数据结构
  • 原文地址:https://blog.csdn.net/beyondx/article/details/126352192