怎么用v-for在遍历渲染这种效果出来,就是有图片有标题有内容的
类似这样,布局用flex也可以,然后把数据渲染到相对应位置就可以了
<div v-for="(item,index) in arr" :key="index">
{{item.title}}
</div>
你可以参考这个布局使用 flex
这个和v-for没有太大的关系,你先用具体数据写好一个样式,然后用v-for,替换一下你的数据就行
大概这个意思:
<template v-for="item in items">
<div style="display:flex;align-items:center;">
<div>
<img :src="item.img">
</div>
<div style="display:flex;flex-direction:column;">
<p>{{item.title}}</p>
<span>作者:{{item.author}}&npsp;发布时间:{{item.publish_time}}</span>
<span>出发地:{{item.address}} 目的地:{{item.mdd}}</span>
<span>{{item.desc}}</span>
</div>
</div>
</template>
写好一条结构,v-for
遍历就可以了
先把静态html+css布局画好,然后再构造数据,再使用v-for遍历,将对应的字段绑定再相应的位置就好了。