![](/img/trans.png)
[英]How to fix Uncaught TypeError: Cannot read property 'pageX' of undefined in Dygraphs?
[英]How to fix TypeError: Cannot read property of undefined?
我的用户界面崩溃了,我收到以下错误:
TypeError: Cannot read property 'filter' of undefined
at v (helper.js:16)
at i (lodash.min.js:9)
at t (lodash.min.js:59)
at value (CheckAll.js:15)
下面是 helper.js 代码的一个片段:
export const updatedChecked = (items, checked) => items.map(item => ({ ...item, checked }));
export const filterChecked = (items, checked) => items.filter(item => item.checked === checked);
export const moveAtTheTop = (items, itemIds) => pureReverse(itemIds).reduce((acc, v) => {
const toCutIndex = acc.findIndex(item => item.id === v);
const toCut = acc.splice(toCutIndex, 1)[0];
toCut.checked = true;
acc.unshift(toCut);
return acc;
}, updateChecked(items, false));
export const normalizeSrcItems = items => filterChecked(items, true).map(item => item.id);
这可能是因为您在调用normalizeSrcItems
时在items
参数中发送了undefined
。 你需要在你调用它的地方检查它
if (items) {
normalizeSrcItems(items)
}
,或者检查为什么你有空物品,也许你以错误的方式得到它
显然,调用
items.filter(...)
看起来项目未定义。 快速修复是:
(items || []).filter(...)
但它可能无法解决问题,为什么项目未定义。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.