
<script type="text/javascript">
var baseUrl = "http://localhost:8080/";
var vm = new Vue({
el: "#container",
data: {
username: "",
userimg: "",
isLogin: false,
indexImgs: [],
categories: []
},
created: function () {
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;
setTimeout(function () {
$('.am-slider').flexslider();
}, 100);
});
var url2 = baseUrl + "index/category-list";
axios.get(url2).then((res)=> {
console.log(res.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