【发布时间】:2019-12-09 15:24:28
【问题描述】:
我有这段代码,如果我注释掉 .then 部分,帖子工作得很好,但如果我把它留在里面,帖子就不会通过。我该如何解决这个问题?
axios.post('http://localhost:5000/exercises/add', exercise)
.then(res => console.log(res.data))
.then(window.location.href = '/')
.catch(err => console.log(err))
【问题讨论】:
-
因为你那里有一个语句..它会被预先执行..将它包装在像
then(function(){window.location.href='/';})这样的函数中
标签: javascript