Vue single page, the page before the form page flashes after submitting the form

scene: single-page application of h5Magi vue opened by Wechat, history mode

process description: open h5 in Wechat, go to the home page-> second-level page-> form page-> submit the form to a third party on the current page, and then the problem arises. The form is submitted by post. Before the third-party page is opened, the form page closes and returns to the second-level page-> after the display time of the second-level page is less than 1s, the third-party page opens

Code

<template>
    ...
    <form method="post"  :action="formData.url" id="postForm" style="display: none"; ref="form">
      <input type="hidden" name="name" v-model="formData.name">
      <input type="hidden" name="tel" v-model="formData.tel">
      <input type="hidden" name="req" v-model="formData.req">
    </form>
    ...
</template>
....
/*  */
request({data}).then((res)=>{
    this.formData = res.data;
    /*  */
    this.$nextTick(()=>{
        this.$refs.form.submit();
    })
})
......

expected result: after submitting the form, jump directly to the third party, there is no splash screen. This kind of problem only appeared in Wechat.


within Wechat, the original form was submitted with the address of ip access, but the problem will not reappear after it is changed to domain name access.

Menu