Vee验证属性或方法“错误”未定义Nuxt JS

问题描述 投票:0回答:1

我正在尝试将Vee Validate安装到我的Nuxt JS v2.6.3应用程序中。我在通用模式下使用Nuxt JS,并在plugins文件夹中添加了vee-validate.js插件文件,该文件的内容为:

import Vue from 'vue';
import VeeValidate from 'vee-validate';

Vue.use(VeeValidate, { inject: false });

然后我使用此文件的nuxt.config.js模式将此文件包含在我的server文件中:

plugins: [
  ...
  { mode: 'server', src: '@/plugins/vee-validate' }
  ...
]

然后,在我的page中,但是我也尝试了一个组件文件,我有一个带有验证的简单输入设置:

pages / apply.vue

<div class="form-group mb-0" v-if="loaded">
  <label class="form-label" for="AppLoanPurposeOther">Please tell us the reason for your loan:</label>
  <input v-validate="'required'" v-bind:class="errors.has('data[ApplicationPayday][AppLoanPurposeOther]') ? 'is-invalid' : ''" name="data[ApplicationPayday][AppLoanPurposeOther]" id="AppLoanPurposeOther" class="form-control form-control-lg" type="text">
</div>

不幸的是,使用此设置,我收到以下控制台错误:

Property or method "errors" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.

这非常令人沮丧,因为它包含在项目中,我拥有Vee Validate版本2.2.7,并且尝试切换Vee Validate JS文件的模式,我尝试使用:inject: trueinject: false ,运气不好。

我想念什么?

javascript vue.js vuejs2 nuxt.js vee-validate
1个回答
0
投票

@ ryan-holton,你知道吗?

© www.soinside.com 2019 - 2024. All rights reserved.