reactjs - 路由未在嵌套路由组件内加载组件
问题描述
我正在加载我的adminDashboard
组件。现在基于 URL,我想渲染一些组件。但是,它没有加载任何组件。此外,chrome 控制台中的网络选项卡上没有任何活动。app.js
Route
adminDashboard
如果我在没有 Route 的情况下渲染它们,它们会正确渲染。
应用程序.js
class App extends Component {
render() {
let { error, success } = this.props;
const Admin = Authorization(['admin'])
return (
<div className='app'>
<AdminNavbar logout={this.props.logout}/>
<Switch>
<Route exact path='/admin/signin' render={(props) => {
return <AuthForm />
}}
/>
<Route exact path='/admin' component={Admin(AdminDashboard)} />
</Switch>
<Footer />
</div>
);
}
}
MyComponent 组件
const MyDashboard = (props)=> ` this is dashboard`
管理仪表板
class AdminDashboard extends Component{
render() {
return (
<div>
<div className='row'>
<div className='col-md-2'>
<NavBar />
</div>
<div className='col-md-10'>
< Commisions /> //working properly if i load it without route
<Switch>
<Route exact path='/admin/dashboard' component={MyDashboard} /> // not work
//some other route
</Switch>
</div>
</div>
</div>
)
}
}
解决方案
推荐阅读
- angularjs - Angular Ui-Grid Excel 导出格式
- python - 在python中制作多种类型的列表元素
- c# - 在 C# 中将字节 [3] 转换为字节 [2]
- visual-studio - 使用脚本在 VSTS 中创建自定义构建定义
- python - 如何使用逗号分隔符将数字保存为python中的整数作为字符串存储
- python - Keras 回归的 GridSearch 实现
- ballerina - Ballerina wso2/gmail 包:无法导入
- javascript - 将文本从 div 复制到输入 javascript
- grafana-alerts - 当数据在 x 分钟内没有变化时发出 Grafana 警报
- jsf - 如何在 PrimeFaces 的芯片中使用属性自动完成