英文:
React use static html page as start page
问题
我有一个React应用程序,起始页面需要是由美术团队创建的静态HTML页面。问题是我无法让路由器从“/”重定向到静态页面:
<Redirect from="/welcome/index.html" to="/welcome/index.html" />
因为它会通过React的主页传递所有内容(由于单页应用程序的逻辑)。我尝试过创建一个包含静态页面代码的组件,但我一直收到许多错误,我不知道如何修复,因为静态页面包含许多我不熟悉的
英文:
I have a React app where the start page needs to be a static html page created by the art team. The problem is that I can't get the Router to redirect from "/" to the static page
<Redirect from="/" to="/welcome/index.html" />
because it passes everything through the React index page (due to the single page application logic). I have tried to make a component with the static page's code in, but I keep getting a lot of errors which I don't know how to fix, as the static page contains a lot of <svg>
tags that I am not familiar with (I could not have created this static page's functionality by myself). Is there any way to do a redirect bypassing React's single page logic?
答案1
得分: 0
找到了解决方案。将“/”重定向到一个名为Welcome的组件:
<Redirect from="/" to="/Welcome" />
在Welcome组件内部,我加入了:
export default function Welcome(){
window.location.href = '/welcome/index.html';
return(
<></>
)
}
英文:
Found a solution. Made "/" redirect to a component called Welcome:
<Redirect from="/" to="/Welcome" />
and inside the Welcome component I put
export default function Welcome(){
window.location.href = '/welcome/index.html';
return(
<>
</>
)
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论