list
组件代码:
<template>
<view>
<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 {
list: [1,2,3,4,5,6,7,8,9,10]
};
}
}
</script>
<style>
</style>
页面代码:
<template>
<view class="content">
<list>
<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>