首页 > 解决方案 > 消息中未打印导入规则的参数 (min_value) - Vee-Validate/Vuetify

问题描述

我正在使用带有 Vee-Validate 的 Vuetify。我在我的组件中导入 vee-validate 和规则:

import { ValidationProvider, extend } from 'vee-validate';
import { min_value } from 'vee-validate/dist/rules';

extend('min_value', {
    ...min_value,
    message: "Must be higher than {length}"
});

然后我有以下内容template

<ValidationProvider :rules="`min_value:${obj.min[selectedUnit]}`" v-slot="{ errors }">
    <v-text-field 
        v-model="obj.value[selectedUnit]"
        :label="key"
        ref="key"
        :min="obj.min[selectedUnit]"
        :max="obj.max[selectedUnit]"
        :error-messages="errors"
        :suffix="selectedUnit"
        outlined
        required
        type="number"
    ></v-text-field>
</ValidationProvider>

该规则有效,但{length}参数未转换为数字。

在此处输入图像描述

最后,在文档中它说min_value是推断的。rules但是当我不提供道具时它根本不起作用。来源https://logaretm.github.io/vee-validate/guide/rules.html#rules

标签: vue.jsvuetify.jsvee-validate

解决方案


发现问题了!

参数被调用min并且可以在文档中找到..

extend('min_value', {
    ...min_value,
    message: "Must be higher than {min}"
});

推荐阅读