vue通过ref改变input的type

template:

<input type="text" ref="input"  v-model="inputPad" @focus="zfocus" @blur="zblur">

data:

inputPad: "请输入支付密码",

methods:

zfocus() {
    this.$refs.input.type = "password"
    if (this.inputPad == "请输入支付密码") {
        this.inputPad = ''
    }
},
zblur() {
    if (this.inputPad == '') {
        this.inputPad = "请输入支付密码"
        this.$refs.input.type = "text"
    }
},

猜你喜欢

转载自blog.csdn.net/qq719756146/article/details/84617548
今日推荐