发布时间:2024-02-05 12:00
本文父组件:shopping.vue
子组件:shoplist.vue
import shoplist from '../shoplist.vue'
components: {
shoplist
}
<shoplist></shoplist>
const shoplistarr = [{
img: "../../static/index/gsdz.png",
shoplistname: "XDT190E托链轮总成(X-G)",
newprice: "354",
oldprice: "354"
}
, {
img: "../../static/img/活动1.png",
shoplistname: "XDT190E托链轮总成(X-G)",
newprice: "354",
oldprice: "354"
}, {
img: "../../static/img/活动2.png",
shoplistname: "XDT190E托链轮总成(X-G)",
newprice: "354",
oldprice: "354"
}, {
img: "../../static/img/我的2.png",
shoplistname: "XDT190E托链轮总成(X-G)",
newprice: "354",
oldprice: "354"
}
]
data() {
return {
shoplistarr
}
},
<shoplist :shoplistarr="shoplistarr"></shoplist>
props: {
shoplistarr: Array
}
直接在<template>里面使用{{shoplistarr}}就可
<view>
<view class="shoplistxq1" v-for="item in shoplistarr">
<img :src="item.img">
<div class="shoplistname1">{{item.shoplistname}}</div>
<div class="newprice1">
¥{{item.newprice}}
<span class="oldprice1">¥{{item.oldprice}}
</span>
</div>
</view>
</view>