Javascript 付款后重定向到其他页面并显示成功消息-Vue JS
我有一个付款模式,一旦用户填写,就会打开,如果付款成功,我想重定向到另一个页面,并显示一条成功消息。我正在使用Laravel 5.3和Vue JS 现在,它看起来是这样的,我让它重定向到另一个页面,但我如何附加某种成功消息Javascript 付款后重定向到其他页面并显示成功消息-Vue JS,javascript,laravel,vue.js,laravel-5.3,httpwebresponse,Javascript,Laravel,Vue.js,Laravel 5.3,Httpwebresponse,我有一个付款模式,一旦用户填写,就会打开,如果付款成功,我想重定向到另一个页面,并显示一条成功消息。我正在使用Laravel 5.3和Vue JS 现在,它看起来是这样的,我让它重定向到另一个页面,但我如何附加某种成功消息 this.$http.post('/cropkit/public/subscriptions', this.$data).then( window.location.replace('/cropkit/public/profile/dashboard'), r
this.$http.post('/cropkit/public/subscriptions', this.$data).then(
window.location.replace('/cropkit/public/profile/dashboard'),
response => this.status = response.body.status
);
/********编辑*********/
以下是检查是否成功或发生错误的解决方案:
是一个警报消息插件
this.$http.post('/mysite/subscriptions', this.$data).then((response) => {
swal({
title: "Success!",
text: "Payment has been processed!",
type: "success",
showConfirmButton: false,
allowEscapeKey: false,
allowOutsideClick: false,
timer: 5000,
}),
setTimeout(function(){
window.location.replace('/mysite/profile/dashboard');
}, 4000)
}, (response) => {
this.status = response.body.status
});
您可以使用错误回调
return this.$http.post(url, data).then((response) => {
// success, do success logic
}, (response) => {
// redirect to error view
});
是的,谢谢,效果很好!顶部编辑的解决方案