Javascript vForm错误无法在表单中为用户显示

Javascript vForm错误无法在表单中为用户显示,javascript,laravel,vue.js,Javascript,Laravel,Vue.js,这是我的表格 <form @submit.prevent="updatePassword"> <div class="form-group"> <label>Old Password</label> <input v-model="form.old_password" type="

这是我的表格

 <form @submit.prevent="updatePassword">

                        <div class="form-group">
                            <label>Old Password</label>
                            <input v-model="form.old_password" type="password" name="old_password"
                                   class="form-control" :class="{ 'is-invalid': 
form.errors.has('old_password') }">
                            <has-error :form="form" field="old_password"></has-error>
                        </div>

                        <div class="form-group">
                            <label>New Password</label>
                            <input v-model="form.password" type="password" name="password"
                                   class="form-control" :class="{ 'is-invalid': 
form.errors.has('password') }">
                            <has-error :form="form" field="password"></has-error>
                        </div>

                        <div class="form-group">
                            <label>Confirm Password</label>
                            <input v-model="form.password_confirmation" type="password" 
name="password_confirmation"
                                   class="form-control" :class="{ 'is-invalid': 
form.errors.has('password_confirmation') }">
                            <has-error :form="form" field="password_confirmation"></has-error>
                        </div>

   <button :disabled="form.busy" type="submit" class="btn btn-primary">Log In</button>
                    </form>
这在我的laravel后端验证中

public function passwordUpdate(Request $request, $id)
{
    $this->validate($request, [
        'old_password' => 'required',
        'password' => 'required|string|min:8|confirmed',
    ]);
}
当我提交一个空表单时,我希望它会在页面上显示错误供用户查看,但在控制台中获取此错误时不会发生任何事情

呈现错误:“TypeError:\u vm.form.errors.has不是函数”


我没有做对什么?

updatePassword
方法中,您直接使用axios,而当您需要
vform
时,请使用
表单处理它。如下所示:

    methods:{
        updatePassword(){
             this.form.post(`/data/password/update/${this.$parent.userId}`)
                .then((response) => {
                    if(response.data === 'success'){
                        Swal.fire(
                            'Update',
                            'Password Updated Successfully',
                            'success'
                        );
                    }
                })
            })
        },
    },


updatePassword
方法中,您直接使用axios,而当您需要
vform
时,请使用
form来处理它。如下所示:

    methods:{
        updatePassword(){
             this.form.post(`/data/password/update/${this.$parent.userId}`)
                .then((response) => {
                    if(response.data === 'success'){
                        Swal.fire(
                            'Update',
                            'Password Updated Successfully',
                            'success'
                        );
                    }
                })
            })
        },
    },

    methods:{
        updatePassword(){
             this.form.post(`/data/password/update/${this.$parent.userId}`)
                .then((response) => {
                    if(response.data === 'success'){
                        Swal.fire(
                            'Update',
                            'Password Updated Successfully',
                            'success'
                        );
                    }
                })
            })
        },
    },