当我们在做一些逻辑操作的时候,我们需要判断输入框中的值是否是我们所规定的输入的格式
这时,我们可以给输入框添加 ref 的值,
<input placeholder="+86" type="text" ref="content">
通过this.$refs.content 就可以访问到输入框中的值 ,content 名字可以随便起
我们将输入框中的值赋值给data中定义好的login
mounted() {
// console.log(this);
this.login = this.$refs.content
console.log(this.login);
},
然后我们就可以进行输入框的判断了
goLogin(){
if(this.checkedAll && this.login.value.length==11){
this.$router.push('/homePage')
}else{
alert('请阅读、勾选权限并输入正确电话号码')
}
},