<form>
<input class="mdui-textfield-input" id="U-psd" type="password" required/>
<button class="mdui-btn mdui-btn-raised mdui-color-pink mdui-ripple" type="submit" onclick="logon()">登陆</button>
<form>
在 js 中:
const userPassword = document.getElementById("U-psd");
function login() {
let loginUser = new User(userEmail.value, userPassword.value);
console.log(userEmail.value);
}
在 chrome 中设置的断点,命中时报空字符串错误。
checkForm.js:32 Uncaught TypeError: Cannot read property 'value' of null
求大佬指导。
const 值是不可改变吧,初始化时候他肯定没有value,后面就获取不到,试试用var声明
你点击事件html中是logon,js中是login,写错了。其次你可以试试,userPassword.value,应该能拿到input的值。
const userPassword = document.getElementById("U-psd");
这行放到函数里
感觉关键问题,不是提示的是uncaughtType erro,应该是你的userEmail未定义吧,都不存在,哪里来的对应的value