雙層 for 例項
<template>
<div class="icons">
<swiper :options="swiperOption">
<swiper-slide v-for="(page,index) of pages" :key="index">
<div class="icon"
v-for="item of page"
:key="item.id" >
<div class="icon-img">
<img class="icon-img-content" :src="item.img" alt="item.dest" style="opacity: 1;">
</div>
<p class="icon-desc">{{item.dest}}</p>
</div>
</swiper-slide>
</swiper>
</div>
</template>
<script>
export default {
name:'homeicons',
data(){
return{
swiperOption:{
autoplay: false
},
iconlist:[
{
id:'0001',
img:"http://img1.qunarzz.com/piao/fusion/1803/95/f3dd6c383aeb3b02.png",
dest:"景點門票"
},{
id:'0002',
img:"http://img1.qunarzz.com/piao/fusion/1804/ff/fdf170ee89594b02.png",
dest:"深圳必遊"
}
,{
id:'0003',
img:"http://img1.qunarzz.com/piao/fusion/1804/5a/13ceb38dcf262f02.png",
dest:"一日遊"
}
,{
id:'0004',
img:"http://img1.qunarzz.com/piao/fusion/1803/76/eb88861d78fb9902.png" ,
dest:"動植物園"
}
,{
id:'0005',
img:"http://img1.qunarzz.com/piao/fusion/1803/27/dac2bcf9added702.png",
dest:"海濱海島"
}
,{
id:'0006',
img:"http://img1.qunarzz.com/piao/fusion/1803/b1/528a9e80403b8c02.png",
dest:"玩轉長隆"
} ,{
id:'0007',
img:"http://img1.qunarzz.com/piao/fusion/1803/76/eb88861d78fb9902.png" ,
dest:"動植物園"
}
,{
id:'0008',
img:"http://img1.qunarzz.com/piao/fusion/1803/27/dac2bcf9added702.png",
dest:"海濱海島"
}
,{
id:'0009',
img:"http://img1.qunarzz.com/piao/fusion/1803/50/26ffa31b56646402.png",
dest:"海洋館"
}
]
}
},
computed:{
pages(){
const pages=[]
this.iconlist.forEach((item,index) => {
const page=Math.floor(index/8)
if(!pages[page]){
pages[page]=[]
console.log(111)
}
pages[page].push(item)
console.log("計算屬性"+page+"==>"+pages[page])
});
return pages
}
}
}
</script>
<style lang="stylus" scoped>
@import '~styles/varibles.styl'
@import '~styles/min.styl'
.icons>>> .swiper-container
height 0
padding-bottom 50%
</style>
相關文章
- OpenHarmony雙網路卡配置例項
- jQuery點選滑出層效果程式碼例項jQuery
- OpenStack Q版雙機部署-啟動例項
- Vue使用Ref跨層級獲取元件例項Vue元件
- CSS3圖層陰影程式碼例項CSSS3
- Qt5雙緩衝機制與例項QT
- OC底層原理之例項、類物件、元類物件物件
- Android系統服務編寫例項-Binder(Java層AIDL)AndroidJavaAI
- php例項化物件的例項方法PHP物件
- PDF轉雙層或者讀雙層PDF中的文字
- unittest例項
- OkHttpClient例項HTTPclient
- jQuery 例項jQuery
- 單例雙重校驗及IF語句的位元組碼層面的原因理解單例
- Activiti的流程例項【ProcessInstance】與執行例項【Execution】
- 策略模式例項模式
- Draggable 拖拽例項
- python例項1Python
- 類和例項
- pinctrl使用例項
- SQLMAP 例項COOKBOOKSQL
- Java例項教程Java
- expect使用例項
- 例項化list
- msfvenom使用例項
- ORM 例項教程ORM
- python socket例項Python
- Proxy例項set()
- 如何區分例項化網格中的每個例項
- 如何將獨立例項轉換成叢集例項EU
- PHP+jQuery-ui拖動浮動層排序並儲存到資料庫例項PHPjQueryUI排序資料庫
- Java--例項化Java
- Makefile例項學習
- python鬧鐘例項Python
- SoapUI入門例項UI
- Oracle Far Sync例項Oracle
- python 類和例項Python
- TypeScript入門例項TypeScript