[英]TypeError: Cannot read property 'indexOf' of undefined
Node is giving this error while checking the occurrence of a substring:节点在检查子字符串的出现时出现此错误:
TypeError: Cannot read property 'indexOf' of undefined'
类型错误:无法读取未定义的属性“indexOf”
var withdraw = project.withdrawal; var uemail = user.eamil; var ans = withdraw.indexOf(uemail) > -1;
The variable withdraw is most likely undefined.变量撤回很可能是未定义的。 Can you default it to an empty string with:
您可以将其默认为空字符串:
var withdraw = project.withdrawal || "";
That should avoid the error, but it might be better to check if there's another error causing withdrawal to be undefined.这应该可以避免错误,但最好检查是否有另一个错误导致提款未定义。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.