【问题标题】:Laravel redirect does not work when posting to Laravel from Vue从 Vue 发布到 Laravel 时,Laravel 重定向不起作用
【发布时间】:2020-07-15 07:17:46
【问题描述】:

在下面写下我的例子。

目前,我在 /user/edit.

Laravel API 代码

public function update(Request $request)
{
  /** here update user code **/

  return redirect()->to('/home')
}

Vue 代码

axios.post('/api/user/' + this.userId, formData).then(res => {
  console.log('success!')
}

但是,不执行重定向。我还在 /user/edit 中。

Laravel 和 Vue 配置的情况下,通过 API 发帖时,重定向过程是不是必须在 Vue 中写?

【问题讨论】:

    标签: laravel vue.js


    【解决方案1】:

    我必须在 Vue 中编写重定向过程吗?

    是的,你是对的。您可以通过回调中的window.location.href = '/home'; 来完成。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-11-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-25
      • 2014-10-02
      • 1970-01-01
      相关资源
      最近更新 更多