![](/img/trans.png)
[英]JavaScript runtime error: Unable to get property 'length' of undefined or null reference
[英]Handle exception “JavaScript runtime error: Unable to get property 'length' of undefined or null reference” on ko.observable field?
我在注册表上使用Knockoutjs。 用户单击按钮以显示密码字段时出现运行时错误
JavaScript运行时错误:无法获取未定义或空引用的属性“ length”
如何处理KO.js中的运行时异常?
self.showHidePasswordField = function () {
if (self.password1().length > 0 || typeof self.password1().length !== 'undefined') {
console.log('show');
} else {
console.log('hide');
}
};
假设您确定定义的password1
可观察的,则可以尝试以下操作:
if (self.password1() != null && typeof self.password1().length !== 'undefined')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.