在写vue项目的时候,控制台总是报错如下代码:

1、Uncaught TypeError: Cannot read properties of null (reading ‘setAttribute‘)

主要是因为某些代码书写不规范,导致templete解析不出来,从而报错

vue项目控制台报错信息问题记录:Uncaught TypeError: Cannot read properties of null (reading ‘setAttribute‘)

解决方案:

检查下自己的代码块中是否使用了el-dropdown的组件,并且<el-dropdown>和 <el-dropdown-menu>一定要配合使用,就算 <el-dropdown-menu>里面没有内容,也要写上。

再运行下代码,就没有报错信息了。

<el-dropdown>

        <el-dropdown-menu></el-dropdown-menu>

<el-dropdown>

vue项目控制台报错信息问题记录:Uncaught TypeError: Cannot read properties of null (reading ‘setAttribute‘)

 2、Vue-TypeError: Cannot read properties of undefined (reading ‘label‘)

vue项目控制台报错信息问题记录:Uncaught TypeError: Cannot read properties of null (reading ‘setAttribute‘)

vue项目控制台报错信息问题记录:Uncaught TypeError: Cannot read properties of null (reading ‘setAttribute‘)

问题:直接在标签上使用{{ labelList[0].label }},会报上面的错误

 vue项目控制台报错信息问题记录:Uncaught TypeError: Cannot read properties of null (reading ‘setAttribute‘)

解决方案:加个数组长度length > 0 的判断即可解决。v-if="labelList.length>0"

vue项目控制台报错信息问题记录:Uncaught TypeError: Cannot read properties of null (reading ‘setAttribute‘)

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。