React router & Phonegap - First page not found

时间:2016-02-12 20:20:32

标签: cordova reactjs phonegap-build react-router

I have a react app using react router.

When i bundle this up into phonegap and connect to it using the phonegap app on my iPhone, i go straight to my 404 (not found) page.

From my 404 page i am then able to navigate to the rest of my app (if i include the menu on the page)

Below is my react router code, has anyone faced a similar issue?

actions = {"a1", "a2", "a3"}
informations = {"i1", "i2", "i3"}
p = argparse.ArgumentParser()
# Contents of actions and informations contrived
# to make the example short. You may need a series
# of calls to add_argument to define the options and
# constants properly
for ai in actions + informations:
    p.add_argument("--" + ai, action='append_const', const=ai, dest=infoactions)

args = p.parse_args()
if not args.infoactions:
    p.error("At least one action or information required")
elif len(actions.intersection(args.infoactions)) > 1:
    p.error("At most one action allowed")

1 个答案:

答案 0 :(得分:2)

我最近遇到了类似的问题,并且能够使用routerHistory代替默认browserHistory来解决此问题。

具体实现方式取决于您所使用的React Router版本。

我按照v2.0迁移指南来实现它:

https://github.com/reactjs/react-router/blob/095ed6cf51d3c4755f13b428182e8ec2df593277/upgrade-guides/v2.0.0.md#using-custom-histories