laravel - Bootstrap vue modal,错误在我提交表单后不会立即显示,仅在我提交表单并尝试在输入字段中输入内容后显示
问题描述
仅在我提交数据并在输入字段中键入内容后,模态才会显示错误。我希望它在我提交表单后立即显示。如何修复这是我的输入字段,
<b-form-group
label-cols-sm="2"
label="Confirm Password"
label-for="example-hf-email2"
>
<b-form-input
name="password_confirmation"
class="form-control-alt"
type="password"
v-model="form.password_confirmation"
></b-form-input>
<div v-if="errors['password_confirmation']">
<div v-for="err in errors['password_confirmation']" :key="err">
<small class="text-danger">{{ err }}</small>
</div>
</div>
</b-form-group>
这是更新的方法。并在 this.error 键中获取错误
methods: {
updatePassword() {
this.submitted = true;
this.errors = {};
var self = this;
axios
.put("/users/" + this.value, this.form)
.then(function (response) {
swal({
title: "Success",
text: "Password updated successfully!",
icon: "success",
}).then(function () {
self.$emit("close-modal");
self.$router.go();
});
})
.catch((err) => {
if (err.response.status == 422) {
this.has_error = true;
Object.assign(this.errors, {}, err.response.data.errors);
}
});
},
},
}
解决方案
推荐阅读
- google-app-engine - 来自 JSON 的 gcloud auth activate-service-account 设置当前项目
- python - 如何在给定的python文件路径中返回错误行?
- angular - 如何避免在 Angular 中暴露内部组件
- c# - 如何关闭打开的视图,不管它是否是活动视图?(Revit 2017、2018、2019)
- javascript - 如何缩小嵌套属性
- excel - 给定两张数据表,我想在第三张表上显示差异
- laravel-5 - 如何在数组映射函数中使用碳计算年龄?
- javascript - 引导日历:清除日期会禁用日历
- c++ - 以下两个涉及自动返回类型的声明是否相同?如果是这样,为什么?
- python-3.x - Python电子邮件正文阅读获取编码数据