el-input type="password" autocomplete="off" 不起效果,还是会默认加载浏览器缓存密码填充
时间: 2023-07-06 20:38:03 浏览: 55
如果你使用的是 Chrome 浏览器,可以尝试在 input 标签中添加 `autocomplete="new-password"` 属性,这样浏览器就不会自动填充密码。如果还是不起作用,可以在 input 标签外面套一个 form 标签,并设置 `autocomplete="off"`属性。例如:
```html
<form autocomplete="off">
<el-input type="password" autocomplete="new-password"></el-input>
</form>
```
这样就可以禁用浏览器的密码自动填充功能了。但需要注意的是,某些浏览器可能不支持 `autocomplete="new-password"` 属性。
相关问题
el-form :model="ruleForm" status-icon :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm"> <el-form-item label="密码" prop="pass"> <el-input type="password" v-model="ruleForm.pass" autocomplete="off"></el-input> </el-form-item>
这段代码是一个基于 Element UI 的表单组件,通过 `:model` 属性绑定了一个名为 `ruleForm` 的数据对象,用于存储表单中各个字段的值。其中包含一个名为 `pass` 的密码字段,使用 `<el-input>` 组件来实现输入框,且输入框的类型为密码输入框。
通过 `:rules` 属性绑定了一个名为 `rules` 的验证规则对象,用于对表单进行验证。同时,还设置了表单的样式和标签宽度。通过 `ref` 属性可以在代码中获取这个表单组件的实例,例如可以通过 `this.$refs.ruleForm.validate()` 来手动触发表单的验证。
<el-form-item label="预约时间"> <el-input size="small" v-model="form.costime" type="date" autocomplete="off"></el-input> </el-form-item>这里面的type类型的date接收的时间会提前一天怎么修改成当前时间
这个问题可能是由于时区的问题导致的。在JavaScript中,Date对象中的UTC时间是标准时间,而其他时间则是根据本地时区进行的计算。因此,当我们在Date对象中传递一个本地时间时,它会被转换为UTC时间。如果你想要使用当前时间来初始化输入框,可以使用以下代码:
```html
<el-form-item label="预约时间">
<el-input size="small" v-model="form.costime" :value="getCurrentDate()" type="date" autocomplete="off"></el-input>
</el-form-item>
```
```js
methods: {
getCurrentDate() {
const now = new Date();
const year = now.getFullYear();
const month = String(now.getMonth() + 1).padStart(2, '0');
const date = String(now.getDate()).padStart(2, '0');
return `${year}-${month}-${date}`;
}
}
```
这里我们通过getCurrentDate方法获取当前的年月日,并将其格式化为YYYY-MM-DD的字符串,然后将其绑定到输入框的value属性上。这样就可以在输入框中显示当前的日期了。