在manifest.json中为mp-weixin设置"slotMultipleInstance" : true
子组件:list.vue
<template>
<view>
<slot name="header" :status="status"/>
<view v-for="(item,index) in list" :key="index">
<slot name="cell" :item="item" :index="index" />
</view>
</view>
</template>
<script>
export default {
name:"list",
data() {
return {
status: 1,
list: [1,2,3,4,5,6,7,8,9,10]
};
}
}
</script>
<style>
</style>
页面:index.vue
<template>
<view class="content">
<list>
<view slot="header" slot-scope="{status}">
Header-{{status}}
</view>
<view class="item" slot="cell" slot-scope="{item,index}" >
item--{{index}}--{{title}}
</view>
</list>
</view>
</template>
<script>
export default {
data() {
return {
title: 'Hello'
}
},
onLoad() {
},
methods: {
}
}
</script>
<style>
.item{
padding: 40rpx;
border-bottom: solid 1px #eeeeee;
}
</style>