首页 文章

React Router基本URL问题和链接标记问题

提问于
浏览
0

我在IIS中托管的ASP.NET Web窗体中有一个现有的应用程序 . 现在我在根目录下创建了一个名为 mobile 的新目录 . 网址就像 - http://domainname/mobile .

应用程序使用React,Redux和React Router编写 . 现在运行应用程序我在Routes.js中进行了如下更改 -

<Router history={history}>
    <Route path='/mobile' component={App}>
        <Route path='/thankyou' component={ThankYou} />
    </Route>
</Router>

主页面已正确加载,因为根组件的路径为“/ mobile” . 但是当我尝试使用链接标记访问thankyou Component时,指向thankyou . 那没起效 .

我尝试了各种更改 - 使用basename或history或react-router github上提供的各种建议解决方案,但这些也无效 . 我的库版本在package.json中

"react": "15.0.2",
"react-dom": "15.0.2",
"react-redux": "4.4.5",
"react-router": "2.4.0",
"react-router-redux": "4.0.4",

任何能够提供baseURL工作解决方案设置为“/ mobile”的人?

可能重复 - React Router

1 回答

  • 1

    如果/ mobile url由服务器提供而不是前端,则根路由应为 / ,如:

    <Route path="/" component={ App }>
        <Route path="thankyou" component={ ThankYou } />
    </Route>
    

    这使得 /mobile/#/thankyou 可以访问 .

相关问题