在iframe中呈现React应用时,导航不起作用

时间:2019-04-10 06:35:13

标签: reactjs iframe routing

我的路线定义如下:

    const routes = [{ 
      path: '/', 
      component: View 
    },
    { 
      path: '/news', 
      component: News 
    }
    ];

和:

<Router>
   <Switch>
      {routes.map((prop, key) => {
         return <Route path={prop.path} component={prop.component} key={key} />;
         })}
   </Switch>
</Router>

在View组件中,我具有链接:

<Link to={`/news`}>News</Link>

此应用已加载到iframe中。链接呈现如下:

<a href="/news">News</a>

但是它不起作用,单击时没有任何反应。 有人遇到同样的问题吗?

0 个答案:

没有答案
相关问题