如何使createObjectUrl()与react-router一起使用?

时间:2019-05-26 09:54:55

标签: react-router react-router-v4 react-router-dom

window.createObjectUrl()创建了一个blob:http://domain/generatedString形状的URL,我试图在<iframe>内使用此URI,但是它似乎不起作用,因为react-router重定向了我如果没有规则匹配,则返回首页,因为它具有如下所示的开关:

<Switch>
  <Route exact path="/" component={Home} />
  <Route exact  path="/a" component={A} />
  <Route exact  path="/b" component={B} />
  <Route component={nomatch} />
</Switch>

如何为这些Blob URI之一制定规则?

2 个答案:

答案 0 :(得分:0)

对我来说,它在JSX中是这样的:

PassThrough

答案 1 :(得分:0)

在浏览器中打开链接时,请不要忘记URL前面的blob:

不要尝试: http://domain/generatedString

但是 blob:http://domain/generatedString

因此不会调用您的react应用,因此react router

相关问题