1
私は異なるルートで2つのレイアウトを適用しようとしています。 ただし、this.props.childrenは、コンテナを期待どおりに表示しません。つまり、this.props.childrenはレイアウトではnullです。複数のレイアウトが反応ルータ4とreduxの下で動作しません
複数のレイアウトを作成するにはどうすればよいですか?
NPMバージョン
├─┬ @types/[email protected]
│ ├── @types/[email protected]
│ └── @types/[email protected] deduped
├─┬ @types/[email protected]
│ ├── @types/[email protected] deduped
│ ├── @types/[email protected] deduped
│ └── [email protected] deduped
ルータ
ReactDOM.render(
<Provider store={store}>
<ConnectedRouter history={history}>
<div>
<Router>
<Switch>
<MainLayout exact path="/" component={IndexContainer as any}/>
<MainLayout path="/index.html" component={IndexContainer as any}/>
<CheckoutLayout path="/checkout/:slotDetailId" component={CheckoutContainer as any}/>
<Route component={NotFound}/>
</Switch>
</Router>
</div>
</ConnectedRouter>
</Provider>
,
document.getElementById('quickpass')
)
export default class MainLayout extends React.Component<any, {}> {
render() {
return (
<div>
<Header />
<Banner />
{this.props.children}
<Footer />
</div>
)
}
}
export class CheckoutLayout extends React.Component<any, {}> {
render() {
return (
<div>
<Header />
<Banner />
{this.props.children}
</div>
)
}
}
更新
要求http://quickpass.com/checkout/762
常にMainLayout 任意のアイデアが一致?
<Provider store={store}>
<ConnectedRouter history={history}>
<Router>
<Switch>
<Route path="/" component={MainLayout} />
<Route path="/checkout" component={CheckoutLayout} />
<Route component={NotFound}/>
</Switch>
</Router>
</ConnectedRouter>
</Provider>
export default class MainLayout extends React.Component<any, {}> {
render() {
return (
<div>
<Header />
<Banner />
<Switch>
<Route exact path='/' component={IndexContainer}/>
<Route exact path='/index.html' component={IndexContainer}/>
</Switch>
<Footer />
</div>
)
}
}
export class CheckoutLayout extends React.Component<any, {}> {
render() {
return (
<div>
<Header />
<Banner />
<Switch>
<Route exact path='/checkout/:slotDetailId' component={CheckoutContainer}/>
</Switch>
</div>
)
}
}
この機能を書くには他の方法があります。それはそうではありません...読みやすい!!とにかくありがとう:) – newBike
この機能を書いて別の方法を示す答えを更新しました。 – palsrealm
リクエスト 'http:// quickpass.com/checkout/762'は常にMainLayoutと一致します アイデアはありますか?あなたは私の更新を確認することができました〜ありがとうございます – newBike