Vue 插件 vee-validate 安装不正确 [英] Vue plugin vee-validate not installing properly

查看:58
本文介绍了Vue 插件 vee-validate 安装不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 vee-validate 插件进行表单验证,而不使用 npm install --save,所以我把dist文件夹中的文件复制到我的项目中,但是由于某些原因我不能正常使用插件.

I'm trying to use the vee-validate plugin for form validation without using npm install --save, so I copied the files in the dist folder into my project, but for some reason I can't use the plugin properly.

这就是我在我的 pug 文件中将插件作为脚本调用的方式 register.pug:

This is how I call the plugin as a script in my pug file register.pug:

block main-content
  .article#register
  form
    input(
      v-model="email"
      v-validate.initial="'required|email'"
      :class="{'input': true, 'is-danger': errors.has('email') }")
block page-specific-scripts
  script(data-minjs-group="register" src="/libs/vue/vee-validate.js")
  script(data-minjs-group="register" src="/scripts/onboarding/register.js")

这是register.js:

(function(doc, win) {
  'use strict';

  var register = new Vue({ 
    el: '#register',
    data: {
      email: ''
    }
  });
})(document, window);

当我重新加载页面时,我收到以下消息:属性或方法错误"未在实例上定义,但在渲染过程中被引用."这不应该是这种情况,因为我认为 errors 是 vee-validate 插件的内置属性.

When I reload the page, I'm getting this message: "Property or method "errors" is not defined on the instance but referenced during render." which shouldn't be the case as I believe that errors is a built-in property of the vee-validate plugin.

推荐答案

你可能还没有添加这个.

You probably haven't added this.

Vue.use(VeeValidate);

(在new Vue之前添加)

这篇关于Vue 插件 vee-validate 安装不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆