zoukankan      html  css  js  c++  java
  • 为什么浏览器记住密码会影响表单?

    用户登录时,用户往往会选择记住密码,由于浏览器自身的问题,当表单中输入框类型为password时,该输入框会有历史记录。效果如下:

    原先的代码:

    <el-row v-if="dialogStatus==='update'?false:true" type="flex" class="row-bg">
    <el-col :span="12">
    <el-form-item label="账户密码:" prop="password">
    <el-input v-model="edit.password" type="password" clearable prop="password"/>
    </el-form-item>
    </el-col>
    </el-row>
    <el-row type="flex" class="row-bg">
    <el-col :span="12">
    <el-form-item v-if="dialogStatus==='update'?false:true" label="确认密码:" prop="checkPassword">
    <el-input v-model="edit.checkPassword" type="password" clearable prop="registeredAddress"/>
    </el-form-item>
    </el-col>
    </el-row>

    修改后的代码:

    <el-row v-if="dialogStatus==='update'?false:true" type="flex" class="row-bg">
    <el-col :span="12">
    <el-form-item label="账户密码:" prop="password">
    <el-input id="pwd" type="password" readonly="true" style="display:none"/>
    <el-input id="hidePwd" v-model="edit.password" type="text" clearable/>
    </el-form-item>
    </el-col>
    </el-row>
    <el-row type="flex" class="row-bg">
    <el-col :span="12">
    <el-form-item v-if="dialogStatus==='update'?false:true" label="确认密码:" prop="checkPassword">
    <el-input id="pwd" type="password" readonly="true" style="display:none"/>
    <el-input id="hidePwd" v-model="edit.checkPassword" type="text" clearable prop="registeredAddress"/>
        </el-form-item>
    </el-col>
    </el-row>

    还需要结合js来处理:即隐藏type为text的输入框,显示type为password的输入框并获取焦点

    openCreateDialog() {
    // 浏览器记住密码会影响表单
    $('#hidePwd').on('focus', function() {
    // 当前文本框隐藏
    $(this).hide()
    // 隐藏的密码框显示并且获取焦点 只读属性去掉
    $('#pwd').show().attr('readonly', false).focus()
    })
    this.userEnterpriseId = this.enterpriseId
    // console.log(this.userEnterpriseId)
    this.resetTemp()
    this.roleShow()
    this.dialogFormVisible = true
    this.disabled = false
    this.dialogStatus = 'create'
    const userType = this.edit.userType
    this.$nextTick(() => {
    this.$refs['from'].clearValidate()
    this.userTypeChange(userType)
    })
    },
  • 相关阅读:
    Selenium断言的使用,等待
    Selenium的鼠标事件,键盘事件
    json,HTTP协议
    HTML,js的基础知识
    Selenium3详解:元素定位方法
    Python操纵Excel,数据库
    Spring拦截器(权限的管理)
    完成登陆功能
    配置使用sitemesh
    Hibernate+pager-taglib实现分页功能
  • 原文地址:https://www.cnblogs.com/zwh0910/p/13965477.html
Copyright © 2011-2022 走看看