首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >VeeValidate表单不会运行提交表单功能

VeeValidate表单不会运行提交表单功能
EN

Stack Overflow用户
提问于 2020-06-04 16:57:03
回答 1查看 180关注 0票数 1

因此,即使ValidationProvider提示错误,我也会输入错误文本,但是submit form应该运行saveAccount。即使文本是可以的,它也不能工作。我没有错误,没有反应,然后我点击提交按钮。我使用的是veeValidate 3.3.0

代码语言:javascript
复制
<template>
  <ValidationObserver v-slot="{ handleSubmit }">  //this and next line seems to won't work
   <q-form @submit="handleSubmit(saveAccount)" > 
         <ValidationProvider rules="secret" v-slot="{ errors }">
           <q-input
             v-model="account.password"
             outlined
             :label="$t('wizzard.password')"
             class="q-mb-sm"
             color="orange-7"
           ></q-input>
           <span>{{ errors[0] }}</span>
         </ValidationProvider>

    <ButtonsBar
      :label="$t('wizzard.Create account')"
      :nextBt="nextBt"
    />

  </q-form>
  </ValidationObserver>
</template>

<script lang="ts">
import { Component, Emit, Mixins } from 'vue-property-decorator'
import { ValidationProvider, ValidationObserver } from 'vee-validate'

...

import './utils/VeeRules'

@Component({
  components: {
    ...
    ValidationProvider,
    ValidationObserver
  }
})

export default class CreateAccount extends Mixins(QuasarStyles) {

  ...

  @Emit()
  saveAccount (): AccountType | false {
    if(this.account.email !== '' && this.account.password !== '' && this.account.password === this.account.confirmPassword){
      return this.account
    } else {
      return false
    }
  }
}

</script>

和VeeRules中的规则:

代码语言:javascript
复制
import { extend } from 'vee-validate';

export const passwordLength = extend('secret', {
  validate: value => value === 'example',
  message: 'This is not the magic word'
}); 
EN

回答 1

Stack Overflow用户

发布于 2020-06-04 21:47:46

您可以尝试在提交时添加.prevent吗?

代码语言:javascript
复制
<q-form @submit.prevent="handleSubmit(saveAccount)" > 
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62190646

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档