Мне нужен gridview, который будет иметь n строк, и каждая строка будет иметь 4 столбца / элемента для отображения. Я хочу добиться использования только Html / Javascript / Vuejs шаблона.
Я хочу получить следующее представление:
На изображении выше у нас есть кнопка «Просмотреть все». Допустим, у нас есть 32 набора данных, в сетке должно быть 8 строк, а в каждой строке будет 4 элемента / столбца. Первоначально мне нужно только две строки (8 элементов для отображения) с «Просмотреть все», и когда я нажимаю на кнопку, он должен развернуться и показать все строки и элементы. с текстом «меньше» когда я нажимаю снова, он должен свернуться и отображать только 2 строки и 8 элементов.
<template>
<div>
<list>
<cell style="flex-direction:row; align-items:center ;" v-for="(rowdata,index) in griddata" :key="index" >
<div v-for="(rowitem, i) in rowdata" style="flex:1;flex-direction:column; backgroundColor:blue;margin:10px;height:100px; align-items:center;" :key="i">
<image class="item-icon" src="https://gw.alicdn.com/tfs/TB1788ygMMPMeJjy1XdXXasrXXa-1919-1520.jpg"></image>
<text style="color:white;justify-content:center;align-items:center;backgroundColor:red;flex:1; text-align:center;">{{rowitem}}</text>
</div>
</cell>
</list>
<text class="view-all-container" v-if="viewText" >{{viewText}}</text>
</div>
</template>
<script>
export default {
props: {
data: Object,
},
data() {
return {
isOpen: false,
viewText: 'View All',
borderRight: 'item-border-right',
appearFlag: [],
griddata:[]
};
},
created() {
for(var i =0;i<5;i++){
var rowdata = []
rowdata.push("1")
rowdata.push("2")
rowdata.push("3")
this.griddata.push(rowdata)
}
},
}
</script>
<style scoped lang="sass?outputStyle=expanded">
.container {
background-color: #fff;
flex-direction: column;
align-items: center;
margin-bottom: 20px;
}
.icon-row {
width: 750px;
flex-direction: row;
align-items: flex-start;
}
.icon {
width: 188px;
height: 168px;
padding-top: 30px;
flex-direction: column;
justify-content: center;
align-items: center;
border-bottom-style: solid;
border-bottom-color: #ebebeb;
border-bottom-width: 1px;
}
.item-border-right {
border-right-style: solid;
border-right-color: #ebebeb;
border-right-width: 1px;
}
.item-icon {
width: 54px;
height: 54px;
margin-bottom: 15px;
}
.item-text {
padding-left: 14px;
padding-right: 14px;
font-size: 22px;
color: #666;
text-align: center;
lines: 2;
height: 64px;
text-overflow: ellipsis;
}
.view-all-container {
width: 750px;
margin-top: 30px;
margin-bottom: 30px;
text-align: center;
font-size: 26px;
font-weight: 500;
color: #ef4e28;
}
</style>
Примечание: я гуглил и проверял в стеке, не смог найти никакого решения. Пожалуйста, помогите мне из этого ..