组件:
<template lang="pug">
view
view 外面的
view(v-for="(item, index) in list" :key="index")
slot(v-bind:item="item")
</template>
<script>
export default {
name: 'inner',
props: {
list: {
type: Array,
default() {
return []
}
}
}
}
</script>
页面中引入此插件:
<template lang="pug">
view
view {{obj.name}}
inner(:list="list" v-slot='{ item }')
view {{obj.name}}
view {{item}}
</template>
<script>
import inner from './inner.vue'
export default {
components: { inner },
data() {
return {
obj: {
name: 'hello'
},
list: [1,2,3,4,5]
}
},
}
</script>