js 常见容错:
1,使用插件时先判断插件是否存在
错误:
if (plugins && plugins.toast && plugins.toast.showShortCenter) { plugins.toast.showShortCenter(message22); } else { alert(message22); }
正确:
if (window.plugins && plugins.toast && plugins.toast.showShortCenter) { plugins.toast.showShortCenter(message22); } else { alert(message22); }
var restoreLoginDialog = function () { var $username = $('#uib_login input[name=username]'); var $password = $('#uib_login input[name=password]'); if (window.localStorage) { if (!$username.val()) { $username.val(localStorage.getItem("user_username")); $password.val(localStorage.getItem("user_password")); } } };