Vuetify 输入自动完成错误

Níc*_*ira 9 vue.js vuetify.js

我试图用谷歌搜索它几次,但没有运气,基本上,当页面加载时,因为密码处于自动保存状态,v-text-field 不理解它并在标签前面呈现密码内容,是否存在任何解决方法或修复?这是一个ss:

在此处输入图片说明

登录组件:

  <template>
  <div>
    <v-card class="elevation-12">
      <v-toolbar color="primary" dark flat>
        <v-toolbar-title>Login</v-toolbar-title>
      </v-toolbar>
      <v-card-text>
        <v-form>
          <v-text-field
            label="E-mail"
            name="email"
            type="text"
            :rules="emailRules"
            :autofocus="'autofocus'"
          ></v-text-field>
          <v-text-field
            id="password"
            label="Senha"
            name="password"
            type="password"
          ></v-text-field>
        </v-form>
      </v-card-text>
      <v-card-actions>
        <v-spacer></v-spacer>
        <v-btn color="primary" block>Logar</v-btn>
      </v-card-actions>
    </v-card>
  </div>
</template>

<script>
  export default {
    name: "LoginForm",
    data: () => ({
      valid: true,
      email: '',
      password:'',
      emailRules: [
        v => !!v || 'Digite um e-mail',
        v => /.+@.+\..+/.test(v) || 'O e-mail precisa ser válido.',
      ]
    })
  }
</script>

<style lang="scss">
@import "LoginForm.scss";
</style>
Run Code Online (Sandbox Code Playgroud)

我使用登录组件的地方:

    <template>
  <v-content>
    <v-container fluid fill-height>
      <v-layout align-center justify-center>
        <v-flex xs12 sm8 md4>
          <LoginForm></LoginForm>
        </v-flex>
      </v-layout>
    </v-container>
  </v-content>
</template>

<script>
import LoginForm from "../components/login/LoginForm";
import Logo from '~/components/Logo.vue'
import VuetifyLogo from '~/components/VuetifyLogo.vue'

export default {
  name: 'Index',
  components: {
    LoginForm,
    Logo,
    VuetifyLogo
  },
  data: () => ({
  }),
}
</script>
Run Code Online (Sandbox Code Playgroud)

dre*_*ker 22

2021 年 6 月 4 日更新。在 Vuetify 2.5.3 和 Google Chrome 90 上测试:

您仍然可以将占位符prop 与一个空格结合使用persistent-placeholder prop。

...
<v-text-field
  label="Login"
  v-model="loginItem.login"
  placeholder=" "
  persistent-placeholder
  :rules="rules.login"
/>
Run Code Online (Sandbox Code Playgroud)

旧答案。此解决方案从 vuetify 2.4.0 开始停止工作(感谢@saike提供信息):

作为一种简单的解决方法,您可以使用一个空格添加占位符道具:

...
<v-text-field
  label="Login"
  v-model="loginItem.login"
  placeholder=" "
  :rules="rules.login"
></v-text-field>
...
<v-text-field
  label="Password"
  placeholder=" "
  v-model="loginItem.password"
  type="password"
  :rules="rules.password"
></v-text-field>
...
Run Code Online (Sandbox Code Playgroud)

这就是在浏览器中保存登录名/密码时的样子(在我的例子中是 Google Chrome 80):

自动保存

并使用空值:

在此处输入图片说明