简体   繁体   English

类型错误:无法读取未定义的属性“indexOf”

[英]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.

相关问题 Javascript TypeError:无法读取undefined的属性'indexOf' - Javascript TypeError: Cannot read property 'indexOf' of undefined 未捕获的类型错误:无法读取未定义的属性“indexOf” - Uncaught TypeError: Cannot read property 'indexOf' of undefined 未捕获的类型错误:无法读取未定义的属性“indexOf” - Uncaught TypeError: Cannot read property 'indexOf' of undefined TypeError:无法读取Node.js中未定义的属性“ indexOf” - TypeError: Cannot read property 'indexOf' of undefined in Nodejs Vueify + Elixir + Hotloading - Uncaught TypeError:无法读取undefined的属性'indexOf' - Vueify + Elixir + Hotloading - Uncaught TypeError: Cannot read property 'indexOf' of undefined 反应-未捕获的TypeError:无法读取未定义的属性'indexOf' - React - Uncaught TypeError: Cannot read property 'indexOf' of undefined 未捕获的TypeError:无法读取angularjs中未定义的属性'indexOf' - Uncaught TypeError: Cannot read property 'indexOf' of undefined in angularjs 未捕获的类型错误:无法读取未定义对象的属性“indexOf” - Uncaught TypeError: Cannot read property 'indexOf' of undefined with Object JavaScript TypeError:无法读取未定义的Exchange消息的属性'indexOf' - Javascript TypeError: Cannot read property 'indexOf' of undefined Exchange Message 雄辩的Javascript:未被捕获的TypeError:无法读取未定义的属性'indexOf' - Eloquent Javascript: Uncaught TypeError: Cannot read property 'indexOf' of undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM