![](/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.