github文档 用着不错,官方的文档例子很简单
<body> <div id="app"> <validator name="validation1"> <form novalidate> <div class="username-field"> <label for="username">username:</label> <input id="username" type="text" v-validate:username="[‘required‘]"> </div> <div class="comment-field"> <label for="comment">comment:</label> <input id="comment" type="text" v-validate:comment="{ minlength: 2 }"> </div> <div class="errors"> <p v-if="$validation1.username.required">Required your name.</p> <p v-if="$validation1.comment.minlength">Your comment is too long.</p> </div> <input type="submit" value="send" v-if="$validation1.valid"> </form> </validator> <script> var vm = new Vue({ el: ‘#app‘ }) </script> </body>
直接用就可以了,自己把CSS改一下,就能用在现在的项目上了。
时间: 2024-10-22 10:30:47