我有一个帖子请求,问题是当我呈现我的 View 时,它呈现到 /link/123
而我希望该 View 呈现到 /anotherlink
我本可以使用 res.redirect ('/anotherlink')
但我需要呈现不同的数据
app.post('/link/:id',function (req, res, next){
res.render('products', {
data : 'help please'
});
});
最佳答案
我找到了一个更好的解决方案,即在不重新加载的情况下更改 View 中的 url:window.history.pushState("", "", '/wantedLink');
关于javascript - 使用 Express 4 更改渲染 View 的 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39308798/