如果存在值且不使用“数字|必需”,如何在Vuetify和vee验证程序中使用“数字”?

问题描述

在下面的代码中,如果存在验证规则(如数字,但不需要),我尝试实现验证。如果规则为“数字”,则验证码不起作用,但如果规则为“数字|必需”,则验证码起作用。

我在github上阅读了此问题 https://github.com/logaretm/vee-validate/issues/383 但这似乎不起作用。

尝试1-

<template>
<ValidationProvider
            ref="totalquantity"
            name="Stock Total Quantity"
            rules="numeric"
          >
            <v-text-field
              v-model.number="item"
              slot-scope="{
                errors,valid,}"
              clearable
              dense
              :error-messages="errors"
              :success="valid"
              label="Item*"
              type="number"
              outlined
            />
          </ValidationProvider>
</template>
<script>
import { ValidationProvider,extend } from 'vee-validate'
import { required,numeric,regex,integer } from 'vee-validate/dist/rules'
extend('required',required)
extend('numeric',numeric)
extend('regex',regex)
extend('integer',integer)
</script>

尝试2-

:rules="edititem.percustomerqty?'required|numeric':''"

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...