首页 > 解决方案 > 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);
              }
            });
        },
      },
    }

标签: laravelvue.jsvuejs2vuetify.jsbootstrap-vue

解决方案


推荐阅读