vue登陆密码明文和暗文切换

组件:有赞移动端

<template>

<div id="login">

 

<van-nav-bar

title="用户登陆"

/>

 

<van-cell-group>

<van-field

v-model="username"

required

clearable

label="用户名"

placeholder="请输入用户名"

@click-icon="$toast('question')"

/>

 

<van-field

v-model="password"

:type="flag == true?'password':'text'"

label="密码"

placeholder="请输入密码"

:icon="flag == true?'password-view': 'password-not-view'"

@click-icon="changType"

required

/>

</van-cell-group>

<div style="text-align:center; margin:10px 0">

<van-button type="primary" size="small" @click="Login">登陆</van-button>

<van-button size="small" @click="handleClick">取消</van-button>

</div>

 

</div>

</template>

<script>

export default {

data () {

return {

username: '',

password: '',

type: 'password',

flag: true

 

}

},

methods: {

Login(){

if(this.username == '' ){

this.$toast('用户名不能为空');

return

}

if(this.password == '' ){

this.$toast('密码不能为空');

return

}

console.log(this.username, this.password)

},

handleClick(){

this.username = ''

this.password = ''

 

},

changType(){

this.flag = !this.flag

}

}

}

</script>

<style>


 

</style>

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值