问题:
Since I'm using react-router to handle my routes in a react app, I'm curious if there is a way to redirect to an external resource.由于我在 React 应用程序中使用 react-router 来处理我的路由,我很好奇是否有办法重定向到外部资源。
Say someone hits:说有人打:
example.com/privacy-policy
I would like it to redirect to:我希望它重定向到:
example.zendesk.com/hc/en-us/articles/123456789-Privacy-Policies
I'm finding exactly zero help in avoiding writing it in plain JS at my index.html loading with something like:我发现在我的 index.html 加载中避免在纯 JS 中编写它的帮助为零,例如:
if ( window.location.path === "privacy-policy" ){
window.location = "example.zendesk.com/hc/en-us/articles/123456789-Privacy-Policies"
}
解决方案:
参考一: https://en.stackoom.com/question/2u442参考二: https://stackoom.com/question/2u442