【发布时间】:2021-08-15 19:56:50
【问题描述】:
我创建了一个组件来作为其他项目的盒子,我正在使用 v-for 在我的页面中拥有四个这样的盒子。通过这种方式,它们只显示在一列中(我无法更改它),但对于台式机,我每行需要两个框,对于移动设备,我需要将它们显示在一列中。我已经有了页脚和背景,但它们没有使用 flexbox,所以我只想能够更改这些框而无需更改其他组件。
App.Vue 代码:
<template>
<div id="app">
<Background />
<div v-for="cliente in clientes" :key="cliente.id">
<Steps :cliente="cliente"/>
</div>
<Footer/>
</div>
</template>
<script>
import Steps from './components/Steps.vue'
import Footer from './components/Footer2.vue'
import Background from './components/Background.vue'
export default {
name: 'App',
components: {
Steps,
Background,
Footer
},
data(){
return{
clientes:[
{
id: 1,
name:"Detalhes da Partida"
},
{
id: 2,
name:"Jogadores"
},
{
id: 3,
name:"Evidência da Partida"
},
{
id: 4,
name:"Mensagem: (opcional)"
}
]
}
}
}
</script>
<style>
html, body {
margin: 0;
padding: 0;
box-sizing: border-box;
background-color: #3B3B3B;
}
</style>
组件代码:
<template>
<section class="flex">
<div>
<p class="teste">{{cliente.id}}. {{cliente.name}}</p>
</div>
</section>
</template>
<script>
export default {
name: 'Steps',
props:{
cliente: Object
}
}
</script>
<style>
*{
margin: 0;
padding: 0;
}
.teste{
color: #FFF;
border-bottom: 1px solid #707070;
padding: .5em .5em 0;
}
.flex {
display: flex;
flex-wrap: wrap;
max-width: 32em;
height: 30em;
background-color: #232323;
margin: 1em auto;
}
.flex > div {
flex: 1 1 100px;
}
</style>
【问题讨论】: