首页 > 其他 > 详细

vue3 生产环境报Cannot read property 'insertBefore' of null

时间:2021-08-21 15:20:44      阅读:17      评论:0      收藏:0      [点我收藏+]

报错出现场景

本人使用的是vue 3.x UI使用的是element-plus ,开发环境不会报错,打包后 报错

技术分享图片

排查后发现都是el-table-column 组件 报错 导致虚拟dom 进行diff算法是报错

错误分析

<el-table-column prop="typeId" align="center" label="类型">
    <template #default="scope">
        <div>
            {{
            	remarkTypeList.filter(v => v.id == scope.row.typeId)[0]?.name   // 数据一开始,这里的下标[0]undefined 
            }}
        </div>
    </template>
</el-table-column>
 <el-table-column prop="attr" width="160" label="报关属性">
     <template #default="scope">  
         <el-select                   
             v-model="scope.row.attr[0].childrenChecked"    																	
             placeholder="请选择" >						
             .....

         </el-select>
     </template>
</el-table-column>
// 一开始 tableData是[]时, 导致 scope.row是{},.attr就是undefined,后面的自然报错
// 没搞明白tableData是[]时, 为什么位运行scope.row.attr[0].childrenChecked,

 <el-table-column prop="list" label="字段信息">
     <template #default="scope">
         <span>{{ tempFilter(scope.row.field) }}</span>
     </template>
</el-table-column>
 const tempFilter = (field => {    
     let arr = field.split(‘|‘)  // 同上 一开始 tableData是[]时, 导致 scope.row.field是undefined,.split 报错
     ...
 }
     // 也没搞明白为什么一开始会走

希望对大家有所帮助

vue3 生产环境报Cannot read property 'insertBefore' of null

原文:https://www.cnblogs.com/little-oil/p/15169202.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!