-1
我正在將我的代碼移植到Vue.js,這對Vue來說非常新穎。正如你所看到的截圖(下面的鏈接),div裏有4列與columns
類名稱。和我試圖使用索引,如v-if='index % 4 === 0'
,但我無法訪問索引出v-for
循環。如何使用Vue實現這個功能?
這就是我想要做的。 https://i.stack.imgur.com/aO2Rx.png
<template lang="pug">
.container
.columns // add this after every 4 coulmns
.column.is-3.vid(v-for='(item,index) in items')
.panel
p.is-marginless
a(:href='item.videoId')
img(:src='item.thumbnail')
.panel.vidInfo
.columns.hax-text-centered
.column
.panel-item.reddit-ups
span {{ item.score }}
i.fa.fa-reddit-alien.fa-2x
.panel-item.reddit-date
i.fa.fa-calendar.fa-2x
</template>
爲什麼你會渲染與v中的項目相關的東西 - for v-for? – Potray
@Potray你認爲還有其他方法可以做到這一點嗎?檢查這個https://i.stack.imgur.com/aO2Rx.png並告訴我吧! – yaomohi
不知道「項目」的內容 – Potray