首页 > 代码库 > Swiper thymeleaf
Swiper thymeleaf
html页面:
<div class="swiper-container swiper_tjzt"> <div class="swiper-wrapper"> <div class="swiper-slide" th:each="i : ${#numbers.sequence( 1,((#lists.size(tagListInfos)%8==0)?(#lists.size(tagListInfos)/8):(#lists.size(tagListInfos)/8+1)))}"> <div class="weui-grids"> <th:block th:each="tagInfos,iterStat:${tagListInfos}" > <th:block th:if="${iterStat.count<=8*i and iterStat.count>=(8*(i-1)+1)}"> <a class="weui-grid" th:onclick="‘javascript:listBybq(\‘‘+${tagInfos.id}+‘\‘,\‘‘+1+‘\‘);‘"> <div class="weui-grid__icon"> <img th:src="http://www.mamicode.com/@{${tagInfos.bqurl}}" /> </div> <p class="weui-grid__label" th:text="${tagInfos.bqname}"></p> </a> </th:block> </th:block> </div> </div> </div> <div class="swiper-pagination pagination_tjzt"></div> </div>
js部分:
var mySwiper = new Swiper(‘.swiper_tjzt‘, { pagination: ‘.pagination_tjzt‘, // paginationClickable: true, spaceBetween: 30, });
后端返回json数据实例:
{ "code": "0","msg": "请求成功","data": [{"id":"","bqname": "亲子","bqurl": "图片路径"
},
{"id":"","bqname": "自驾","bqurl": "图片路径"},{"id":"","bqname": "蜜月","bqurl": "图片路径"},{"id":"","bqname": "古镇","bqurl": "图片路径"},{"id":"","bqname": "爸妈游","bqurl": "图片路径"},{"id":"","bqname": "山水游","bqurl": "图片路径"},{"id":"","bqname": "健康养生","bqurl": "图片路径"}]}
java后台封装:
model.addAttribute("tagListInfos",service.获取接口方法返回的json数据());
最终实现效果为:
thymeleaf 学习文档
http://www.open-open.com/lib/view/open1451625468230.html
Swiper thymeleaf
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。