我正在尝试通过以下方式验证所有输入
this.validator.validateAll().then((result) => {
console.log(result)
}).catch(() => {
// something went wrong (non-validation related).
return false;
});
但出现错误
Cannot read property 'then' of undefined
当我检查时
console.log(this.validator)
函数 validateAll 不存在。之前上面的方法一直有效,直到今天
以下是我的 package.json 依赖项
"devDependencies": {
"vue": "^2.1.10"
},
"dependencies": {
"vee-validate": "^2.0.0-rc.21",
}
运行后开始抛出错误可能出了什么问题
npm install vee-validate --save
我需要做什么,因为它以前工作过?
最佳答案
This.validator
表示您想要访问 Vue 组件属性。但插件使用 this.$validator
这是插件本身注入(inject)的属性。
http://vee-validate.logaretm.com/examples.html#validate-form
关于javascript - Vuejs vee validate 验证所有表单输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47263647/