我想从“电子邮件”类型的输入字段中获取输入值,但我得到的是 NaN。value.password正在工作,我能够获得该password领域的价值,但document.getElementById('em-id').value正在给我NaN.
请帮我解决这个问题。
我的代码片段如下
<div class="email-div">
<i class="fas fa-user-shield"></i>
<input type="email" name="email" id="em-id" placeholder="Email" min="3" max="15"
spellcheck="false" required="true">
</div>
<div class="pass-div">
<i class="fas fa-lock"></i>
<input type="password" name="password" id="pass" placeholder="Password" min="8" max="32"
spellcheck="false" required="true">
</div>
<div class="btn-div">
<button class="btn" id="login-btn" v-on:click="login">LOGIN</button>
</div>
login: function() {
let email = document.getElementById('em-id').value
let password = document.getElementById('pass').value
if(email && password) {
console.log('email => ', + email) //gives output Nan
console.log('password => ' + password)
}
}
收到一只叮咚
慕村225694
跃然一笑
相关分类