vue3+element-plus 报错:Cannot read properties of null (reading ‘insertBefore‘)

原因:

el-table-column渲染时报错

Error: Cannot read properties of null (reading 'insertBefore')
<el-table-column align="center" :width="100" label="查看详情">
    <template #default="scope">
        <el-button
            v-if="scope.row.detail.length > 0"
            @click="detail(scope.row)"
            size="small"
            type="primary"
        >查看el-button>
    template>
el-table-column>

scope.row.detail未找到,导致虚拟dom渲染报错

解决:

需要先判断它是否存在scope.row.detail?.length > 0

你可能感兴趣的:(vue,vue3,vue.js,前端,javascript)