TypeError: Cannot read properties of undefined (reading 'filter')
时间: 2023-10-15 21:29:58 浏览: 242
Vue打包Cannot read property 'tapPromise' of undefined报错处理.docx
5星 · 资源好评率100%
这个错误是由于尝试在undefined对象上读取"filter"属性造成的。具体来说,错误发生在这行代码上:typeof(_this.Type_Ary.filter((data) => data.CODE == row.DEP_TYPE)) =="undefined"。当"_this.Type_Ary"是undefined时,在它上面调用"filter"方法就会导致这个错误。为了修复这个错误,可以在方法中添加一个判断条件来检查"_this.Type_Ary"是否存在并且不是undefined,只有在这种情况下才执行"filter"方法的调用。下面是修复后的代码示例:const formatter_DepType = function (row, column) { if (_this.Type_Ary && row.DEP_TYPE) { if(typeof(_this.Type_Ary.filter((data) => data.CODE == row.DEP_TYPE)) =="undefined"){ return ""; } return _this.Type_Ary.filter((data) => data.CODE == row.DEP_TYPE).NAME; } return ""; }<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* *3* [TypeError: Cannot read properties of undefined (reading ‘NAME‘)报错解决](https://blog.csdn.net/guapilixianghe/article/details/129284383)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"]
[ .reference_list ]
阅读全文