给 el-input 元素添加 readonly 属性,并在 el-input 元素获得焦点时,移除 readonly 属性。
关键代码:
readonly οnfοcus="this.removeAttribute('readonly');"
elementui 禁止浏览器自动填充密码,代码示例如下:
<el-form-item
v-show="dialogType === 'add'"
label="密码"
prop="password"
title="密码强度要求:需包含大小写字母、数字、特殊字符,长度6-20位"
>
<span class="required_icon">*</span>
<el-input
v-model="editAddForm.password"
:maxlength="255"
type="password"
placeholder="请输入密码"
show-password
style="width: 15vw"
readonly
onfocus="this.removeAttribute('readonly');"
/>
</el-form-item>