Closed yang5664 closed 7 years ago
As far as I know, they're going to remove the validator element.
Have a look at the 3.0 release examples.
The validation and validity components are your new validation components.
i have the somme problem..
You may try this sample code
<template v-fieldset="Test">
<transition name="fade" mode="out-in" appear>
<div class="login_bg">
<div class="login_logo">
</div>
<validation name="login" @submit="handleSubmit">
<div class="login_area">
<h4>請使用下列方式登入帳號:</h4>
<div class="form-group">
<label class="sr-only" for="email">E-mail帳號</label>
<validity ref="email" field="email" :validators="{
required: { message: '請輸入Email !!' }
}">
<input type="text" class="form-control" id="email" placeholder="輸入E-mail帳號" @focusout="handleValidate">
</validity>
</div>
<div class="form-group">
<label class="sr-only" for="password">密碼</label>
<validity ref="password" field="password" :validators="{ required: { message: '請輸入密碼 !!' } }">
<input id="password" type="password" class="form-control" placeholder="輸入密碼" @focusout="handleValidate">
</validity>
</div>
<button type="submit" class="btn btn-default login_btn":disabled="!validated || !valid">登入</button>
<div class="errors">
<p v-for="error in errors">{{error.message}}</p>
</div>
<div class="login_bottom_area">
</div>
</div>
</validation>
</div>
</transition>
</template>
<script>
import { mapValidation } from 'vue-validator'
import { mapActions, mapGetters } from 'vuex'
export default{
data () {
return {
message: 'hello vue',
validated: false
}
},
computed: {
...mapGetters({
}),
...mapValidation({
valid: '$validation.login.valid',
errors: '$validation.login.errors'
})
},
validators: {
confirm: function (val) {
return val === this.$refs.password.$el.value
}
},
methods: {
...mapActions({
}),
handleSubmit: function (e) {
if (!this.validated || !this.valid) {
e.preventDefault()
}
},
handleValidate: function (e) {
var self = this
e.target.$validity.validate(function () {
self.validated = true
})
}
}
}
</script>
it can't insert components in the
vue & vue-validator version
Reproduction Link
Steps to reproduce
App.vue
ValidTest2.vue
app.js
What is Expected?
how can make it work?
What is actually happening?