vue.js表单验证_Vue.js的验证表单

vue.js表单验证

将验证 (willvalidate)

Validation Forms for Vue.js.

Vue.js的验证表单。

建立 (Setup)

安装依赖 (Install dependencies)
npm install willvalidate --save
进入main.js vuejs(单个文件组件) (Into main.js vuejs (Single File Components))
import Vue from 'Vue'
import willvalidate from 'willvalidate'
Vue.use(willvalidate)

用法 (Usage)

例如:方法内 (Ex: within methods)
export default {
  methods:{
    sendForm()
    {
       this.willvalidate( document.querySelector("#form") ) ? console.log("ok") : console.log("error")
    }
  }
}

或在脚本标签中 (Or in script tag)

<script src="./PATH/node_modules/willvalidate/dist/willvalidate.js"></script>
使用Attr html5进行验证 (Use Attr html5 for validation)
Ex: require, maxlength, minlength, type, pattern, min, max and others

定制 (Customize)

# error class 
.has-danger{}

# set errorMessage | optional - if not informed will show default message
Ex: <input type="number" min="5" max="20" errorMessage="Preencha corretamente" required  />

翻译自: https://vuejsexamples.com/validation-forms-for-vue-js/

vue.js表单验证

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值