【发布时间】:2020-09-18 07:53:36
【问题描述】:
我是 vue.js 的新手,目前正在使用 vuetify 进行练习。我试图制作这个布局几个小时,但我仍然卡住了。谁能帮我解释一下如何解决这个问题?
第一张卡片,我将显示描述,第二张卡片,图像。换行时,例如第二行,我会像第四张卡片一样保留图像。第八个和第九个将是文本并从那里继续交替。
<template>
<div class="home">
<v-container grid-list-lg>
<h1>Home</h1>
<v-layout row>
<v-flex lg3 v-for="(item, index) in arr" :key="item.id" class="space-bottom">
<v-card class="mx-auto" max-width="344" outlined>
<v-list-item three-line>
<v-list-item-content v-if="index % 2 === 0" height="400px">
<v-list-item-subtitle>{{item.description}}</v-list-item-subtitle>
<v-list-item-subtitle class="subtitle-style">
<span>
<a href="#">Read more</a>
</span>
</v-list-item-subtitle>
</v-list-item-content>
</v-list-item>
<v-hover>
<template v-slot:default="{ hover }">
<v-list-item-content v-if="index % 2 !== 0">
<img :src="item.imageUrl" />
<v-fade-transition>
<v-overlay v-if="hover" absolute color="#036358">
<v-btn>See more info</v-btn>
</v-overlay>
</v-fade-transition>
</v-list-item-content>
</template>
</v-hover>
</v-card>
</v-flex>
</v-layout>
</v-container>
</div>
</template>
<script>
export default {
props: {},
data() {
return {
arr: [
{
description: "description 1",
imageUrl: "https://via.placeholder.com/100"
},
{
description: "description 2",
imageUrl: "https://via.placeholder.com/100"
},
{
description: "description 3",
imageUrl: "https://via.placeholder.com/100"
},
{
description: "description 4",
imageUrl: "https://via.placeholder.com/100"
},
{
description: "description 1",
imageUrl: "https://via.placeholder.com/100"
},
{
description: "description 1",
imageUrl: "https://via.placeholder.com/100"
},
{
description: "description 1",
imageUrl: "https://via.placeholder.com/100"
},
{
description: "description 2",
imageUrl: "https://via.placeholder.com/100"
},
{
description: "description 3",
imageUrl: "https://via.placeholder.com/100"
},
{
description: "description 4",
imageUrl: "https://via.placeholder.com/100"
},
{
description: "description 1",
imageUrl: "https://via.placeholder.com/100"
},
{
description: "description 1",
imageUrl: "https://via.placeholder.com/100"
}
]
};
}
};
</script>
<style>
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
【问题讨论】:
-
我一遍又一遍地尝试同样的事情,因为我找不到任何其他方法来做到这一点,这就是为什么我决定在这里发帖寻找其他观点。我尝试的是:有两个
第 5 张卡片,它变成了文字,这与我的做法一样正常。很抱歉没有发布我已经尝试过的内容,感谢您的回复。-list-item-content> -
卡片的内容是否会在不同的响应时间间隔内发生变化?
-
我目前正在编辑示例以向您展示。我会在一分钟内发布它。我现在没有让它响应,我两天前才开始学习 Vue:p
-
我刚刚编辑了帖子以插入代码。如果您需要更多信息,请告诉我
标签: javascript html css vue.js vuetify.js