官方文档:http://vuejs.github.io/vue-validator/zh-cn/index.html
github项目地址:https://github.com/vuejs/vue-validator
单独使用vue-validator的方法见官方文档,本文结合vue-router使用。
安装验证器
不添加自定义验证器或者无需全局使用的公用验证器,在main.js中安装验证器,使用 CommonJS 模块规范, 需要显式的使用 Vue.use() 安装验证器组件。
import Validator from 'vue-validator'
Vue.use(Validator)