http://en.jsrun.net/cqiKp/edit
由于页面中使用了css3方法 ul>li*4 margin-right:0;
导致只能用ul允许 存在四个li .不然在ul多了五个li. 页面就不好看了。
// CurriculumSpecial.html
var na1=new Vue({
el:".col-4",
data: {
"ulist":[1,2,3,4],
"course":[
{"url":"http://mooc-10050339.cos.myqcloud.com/course/jiazhangmooc/cthimage/Y010.png","title":"幼儿阶段基础课程","time":"12","baoming":true},
{"url":"http://mooc-10050339.cos.myqcloud.com/course/jiazhangmooc/cthimage/Y010.png","title":"幼儿阶段基础课程","time":"12","bm":true},
{"url":"http://mooc-10050339.cos.myqcloud.com/course/jiazhangmooc/cthimage/Y010.png","title":"幼儿阶段基础课程","time":"12","bm":true},
{"url":"http://mooc-10050339.cos.myqcloud.com/course/jiazhangmooc/cthimage/Y010.png","title":"幼儿阶段基础课程","time":"12","bm":true},
{"url":"http://mooc-10050339.cos.myqcloud.com/course/jiazhangmooc/cthimage/Y010.png","title":"幼儿阶段基础课程","time":"12","bm":true},
{"url":"http://mooc-10050339.cos.myqcloud.com/course/jiazhangmooc/cthimage/Y010.png","title":"幼儿阶段基础课程","time":"12","bm":true},
{"url":"http://mooc-10050339.cos.myqcloud.com/course/jiazhangmooc/cthimage/Y010.png","title":"幼儿阶段基础课程","time":"12","bm":true},
{"url":"http://mooc-10050339.cos.myqcloud.com/course/jiazhangmooc/cthimage/Y010.png","title":"幼儿阶段基础课程","time":"12","bm":true},
// {"url":"http://mooc-10050339.cos.myqcloud.com/course/jiazhangmooc/cthimage/Y010.png","title":"幼儿阶段基础课程","time":"12","bm":true},
// {"url":"http://mooc-10050339.cos.myqcloud.com/course/jiazhangmooc/cthimage/Y010.png","title":"幼儿阶段基础课程","time":"12","bm":true},
// {"url":"http://mooc-10050339.cos.myqcloud.com/course/jiazhangmooc/cthimage/Y010.png","title":"幼儿阶段基础课程","time":"12","bm":true},
// {"url":"http://mooc-10050339.cos.myqcloud.com/course/jiazhangmooc/cthimage/Y010.png","title":"幼儿阶段基础课程","time":"12","baoming":true},
// {"url":"http://mooc-10050339.cos.myqcloud.com/course/jiazhangmooc/cthimage/Y010.png","title":"幼儿阶段基础课程","time":"12","bm":true},
// {"url":"http://mooc-10050339.cos.myqcloud.com/course/jiazhangmooc/cthimage/Y010.png","title":"幼儿阶段基础课程","time":"12","bm":true},
// {"url":"http://mooc-10050339.cos.myqcloud.com/course/jiazhangmooc/cthimage/Y010.png","title":"幼儿阶段基础课程","time":"12","bm":true},
// {"url":"http://mooc-10050339.cos.myqcloud.com/course/jiazhangmooc/cthimage/Y010.png","title":"幼儿阶段基础课程","time":"12","baoming":true},
// {"url":"http://mooc-10050339.cos.myqcloud.com/course/jiazhangmooc/cthimage/Y010.png","title":"幼儿阶段基础课程","time":"12","bm":true},
// {"url":"http://mooc-10050339.cos.myqcloud.com/course/jiazhangmooc/cthimage/Y010.png","title":"幼儿阶段基础课程","time":"12","bm":true},
// {"url":"http://mooc-10050339.cos.myqcloud.com/course/jiazhangmooc/cthimage/Y010.png","title":"幼儿阶段基础课程","time":"12","bm":true},
],
},
created:function(){
// console.log(ulist);
}
})
<ul class="col-4" v-cloak>
<li v-for="st in course">
<i class="icon-baoming" v-if="st.baoming">已报名</i>
<i class="icon-bm" v-if="st.bm">报名</i>
<a href="special/CurriculumSpecial.html"><img :src="st.url" alt="">
<p><span class="f16">{{st.title}}</span> <span class="timeRed">总学时:{{st.time}}</span></p>
</a>
</li>
</ul>
就是每个ul中遍历四个li.一共有四个 。
但data数据是否有误?
在
ul
上加v-for="index of (Math.ceil(course.length / 4))
li
的v-for
改为st in course.slice((index - 1) * 4, (index - 1) * 4 + 4)
这里el选项不能还是".col-4",需要改一下