大佬教程收集整理的这篇文章主要介绍了无法为网格 12 项和列表 8 项分配项目?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
layout: false,computed: {
rows() {
return this.productsList.length;
},paginatedItems() {
return this.productsList.slice(
this.currentPage * this.perPage,(this.currentPage + 1) * this.perPage
);
},},methods: {
layoutchange() {
this.layout = !this.layout;
if (this.layout === truE) {
} else {
}
},
<div class="bar">
<!-- these two buttons switch the layout variable,which causes the correct ul to be shown. -->
<a class="List-icon" v-bind:class="{ active: layout == false }" v-on:click="layoutchange"></a>
<a class="grID-icon" v-bind:class="{ active: layout == true }" v-on:click="layoutchange"></a>
</div>
<ul v-if="layout == true">
<div class="overflow-auto1">
<div class="ListvIEw-plp" v-for="product in paginatedItems" :key="product.key" ID="product" :items="productsList" :per-page="perPage" :current-page="currentPage" </div>
</div>
</ul>
<ul v-if="layout == false" class="grID-vIEw">
<div class="overflow-auto">
<div class="product-plp1" v-for="product in paginatedItems" :key="product.key" ID="product" :items="productsList" :per-page="perPage" :current-page="currentPage">
</div>
</div>
</ul>
无法为网格 12 项和列表 8 项分配项。不知道如何开始。
但在 ul 标签中,我认为我需要分配一些条件,并将其传递给计算属性才能做到这一点。
你能帮我解决这个问题吗?谢谢
您需要在 this.perPage
中设置 layoutChange
:
perPage: 12,layout: false,computed: {
rows() {
return this.productsList.length;
},paginatedItems() {
return this.productsList.slice(
this.currentPage * this.perPage,(this.currentPage + 1) * this.perPage
);
},},methods: {
layoutchange() {
this.layout = !this.layout;
// If layout == true in grid-mode switch the numbers around
this.perPage = this.layout ? 8 : 12;
}
}
以上是大佬教程为你收集整理的无法为网格 12 项和列表 8 项分配项目?全部内容,希望文章能够帮你解决无法为网格 12 项和列表 8 项分配项目?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。