报错:TypeError: Invalid attempt to destructure non-iterable instance.
在小程序中运行正常,模拟器中也正常,到了真机调试时发现报错:
cid unmatched [object Object] TypeError: Invalid attempt to destructure non-iterable instance.
看了网上部分说法:比如for循环引用了未定义的值。
经过修改排除后问题还是存在,在一步步尝试中发现是因为循环渲染了自定义组件导致的。
<slide-action
v-for="(item, index) in folderList"
:key="item.ID"
:class="index === folderList.length - 1 ? 'xxx' : ''"
>
<template #right></template>
</slide-action>
尝试将for循环写在外层嵌套的容器上后不再报错
<div
v-for="(item, index) in folderList"
:key="item.ID"
>
<slide-action
:class="index === folderList.length - 1 ? 'xxx' : ''">
<template #right></template>
</slide-action>
</div>