scoped slot嵌套v-for的作用域指向父级?

在scoped slot中使用v-for,一直报错说props Undefined

<mTable :rows="rows" :header="header">
    <td slot="cell" slot-scope="props" v-for="(value,key) in props.header">
        <a v-bind:class="props.row[key].style">
            {{props.row[key].date}}
        </a>
    </td>
</mTable>

props的结构:

{
  "rowId": 0,
  "row": [
    {"date": 29},{"date": 30},{"date": 31},{"date": 1},
    {"date": 2},{"date": 3},{"date": 4}
  ],
  "header": ["日","一","二","三","四","五","六"]
}

报错信息

[Vue warn]: Property or method "props" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. 

这是因为scoped slot不支持嵌套v-for的原因吗?把props.header换成header,在父级组件中data增加header就不会出错了

阅读 3.2k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题