Uncaught TypeError: Cannot read properties of null (reading 'element')
nnot read properties of null (reading 'index')
错误写法
就是说子组件需要用div包着,你用其他东西,他无法添加key,然后就会报错。
<template #item="{element}">
<Todo :detail="element"></Todo>
</template>
问题
要用div包住自己的子组件
<template #item="{element}">
<div>
<Todo :detail="element"></Todo>
</div>
</template>

当遇到UncaughtTypeError:Cannotreadpropertiesofnull(readingelement)错误时,问题可能在于子组件未被正确的HTML元素(如div)包围,导致无法添加key。修正方法是确保每个子组件都被div等支持的元素包裹,并为这些子组件分配key属性,以避免渲染错误。
5048

被折叠的 条评论
为什么被折叠?



