javascript - CEP 扩展中的 React-router(例如 Premiere Pro)

标签 javascript reactjs react-router adobe complex-event-processing

我正在尝试在 CEP 扩展中使用 react 路由器。我的路由如下所示:

let prefix = decodeURIComponent(window.location.pathname).replace("index.html", "")

  <Router>
      <Switch>
        <Route exact path={prefix + "index.html"} component={MainComponent} />
        <Route path={prefix + "other/:otherId"} component={OtherComponent} />
      </Switch>
  </Router>

这似乎是欺骗路由器接受扩展位置的唯一方法 - 因为它的 document.location 为“file://path/to/cep/extention/index.html”。 我现在面临的问题是,这仅适用于 Mac - 但始终无法匹配 Windows 上的任何路径。我怀疑这是因为 Windows 上的位置如下所示: 'file:///C:/Program%20Files%20(x86)/Common%20Files/...be/CEP/extensions/extension-name/index.html' 和“C:”混淆了路由器?

有什么办法可以欺骗路由器接受这种位置URI吗?

最佳答案

简单的解决方案 - 使用 HashRouter 而不是 BrowserRouter。这也允许使用普通路径:

import { Route, HashRouter as Router, Switch } from 'react-router-dom'
<Router >
  <Switch>
    <Route exact path="/" component={MainComponent} />
    <Route path="/other/:otherId" component={OtherComponent} />
  </Switch>
</Router>

关于javascript - CEP 扩展中的 React-router(例如 Premiere Pro),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55725900/

相关文章:

javascript - 当任何查看 js 代码的人都可以看到 javascript API key 时,它有什么意义

javascript - 尝试在 React w/Formik 中每次输入字段完成时创建一个计数器

javascript - React.js 返回简单的链接列表

javascript - 继续在 telerik 的 radgrid 中显示工具提示

javascript - SignalR 客户端应用程序在 VS2008 中运行时无法连接

javascript - 使用 javascript 使用 SVG 代码填充对象标签

javascript - React.js - 传递函数 "not a function"错误

html - 动态背景图像 react

javascript - 在 React.js 中,如何使用 React-bootstrap 创建链接来更改事件选项卡?

javascript - 如何从 react 表中单击表行转到另一个页面?