组件
<template>
<view class="testcomponent">
<block v-for="row in list" :key="row.id">
<slot name="rowContent" :row="row"></slot>
</block>
</view>
</template>
页面
<template>
<view class="content">
<testcomponent :list="list">
<template slot="rowContent" slot-scope="{ row }">
<text class="text">{{row.name}}</text>
</template>
</testcomponent>
</view>
</template>
<script>
export default {
data() {
return {
list:[
{id:1,name:"测试1"},
{id:2,name:"测试2"},
{id:3,name:"测试3"},
{id:4,name:"测试4"},
{id:5,name:"测试5"},
{id:6,name:"测试6"},
{id:7,name:"测试7"},
{id:8,name:"测试8"},
{id:9,name:"测试9"},
{id:10,name:"测试10"},
{id:11,name:"测试11"},
{id:12,name:"测试12"},
{id:13,name:"测试13"},
{id:14,name:"测试14"},
{id:15,name:"测试15"},
{id:16,name:"测试16"},
{id:17,name:"测试17"},
{id:18,name:"测试18"},
{id:19,name:"测试19"},
]
}
}
}
</script>