【发布时间】:2017-05-13 17:44:57
【问题描述】:
尝试在 IntelXDK 中使用 cordova 插件执行此操作,但它不显示任何内容
const app = document.getElementById('app');
const Index = () => (
<Router>
<div>
<Switch>
<Route exact path="/" component={Layout}/>
<Route path="/about" component={First}/>
<Route path="/topics" component={Second}/>
</Switch>
</div>
</Router>
);
const Layout = () => (
<div>
<h1>layout</h1>
<ul>
<li><Link to="/">Home</Link></li>
<li><Link to="/about">About</Link></li>
<li><Link to="/topics">Topics</Link></li>
</ul>
</div>
);
const First = () => (
<div>
<h1>first</h1>
</div>
);
const Second = () => (
<div>
<h1>second</h1>
</div>
);
ReactDOM.render(<Index/>, app);
当我删除 exact 字而不使用 <Switch> 标记时,它可以工作,但会呈现 2 个组件(布局和第一个或布局和第二个)。
我只想渲染 1 个组件,有人可以帮我解决这个问题吗?
【问题讨论】:
标签: android cordova reactjs react-router intel-xdk