vue组件插槽使用时,有序列表前面的数字都为1

//父组件
<Category title="食品">
            <template scope="scopeData">
                <ol v-for="(item,index) in scopeData.foods" :key="index">
                    <li>{{item}}</li>
                </ol>
            </template>
 </Category>


// 子组件
<template>
    <div class="contains">
        <h3>{{title}}列表</h3>
        <!-- 插槽(作用域使用) -->
        <slot :foods="foods"></slot>
    </div>
</template>

img

为什么有序列表页面中展示的数字都是1呢,怎样才能显示1,2,3,4??

抢答

用索引可以实现1,2,3,4 {{index+1}}

<ol >
  <li v-for="(item,index) in scopeData.foods" :key="index">{{item}}</li>
</ol>

v-for写的位置错误,应该放在li标签上。