Success message displayed in Vue when data is saved successfully
P粉878510551
P粉878510551 2023-08-29 22:36:10
0
1
496
<p><pre class="brush:php;toolbar:false;">axios .post( "/api/product/store",{ id: this.id }) .then((res) => { var variant = "danger"; var icon = "XIcon"; var message = "Thất bại"; if (res.data.error == 0) { var variant = "success"; var icon = "ArrowDownCircleIcon"; var message = res.data.message; window.location.reload(); } this.$toast({ component: ToastificationContent, props: { title: message, icon: icon, variant: variant, }, }); }) .catch((error) => { });</pre> <p>My problem is: it only loads the page when the message is displayed, so when the page reloads it loses the message. Is there a way to reload the previous page and then display the following message? Thanks. </p>
P粉878510551
P粉878510551

reply all(1)
P粉037215587

What’s the point of reloading the page? If you want to display updated data on the user interface, Vue will do it for you automatically. So you don't need to do this.

Alternatively, if page reloading is necessary for you, you can put the prompt message on the root page and call it from the current subpage. In this case, the message will be displayed regardless of whether you reload the page.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template