douyouming9180 2016-10-25 13:37
浏览 59

Drupal7 + ReactJS SPA在应用程序内正确路由

Some weeks ago I have been trying to integrate a simple single page application (SPA) based on react within drupal. Some more details can be foun in this thread.

I have successfully started an application within drupal, now my problem is shifted to another level, that is Routing. I can navigate within the SPA correctly but I cannot interact through the addressbar of the browser, neither the url changes as the content within the spa change. Finally, the back, forward buttons of the browser leave spa page completely

I can imagine that it might be possible to change the address bar url as i navigate within the SPA, (something like http://localhost:8080/node/spa#/path/to/page1 etc.) but i cannot find any relevant tutorial or guide; or to know that is impossible to do such a thing and re evaluate my solution

  • 写回答

1条回答 默认 最新

  • douyu1990 2016-11-18 09:30
    关注

    After doing some trial and error, one way to go properly with the routing of an spa that lives within the drupal CMS is with hashtags, given the fact/limitation that no other component is using the hashtag as a way to do construct urls (e.g. by the theme)

    so the URL of the page will have two parts while being in the SPA page:

    http://drupal/url/to/page#/spa.part

    In this way both drupal and spa work together.

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?