【发布时间】:2019-09-06 22:02:28
【问题描述】:
我有一个使用 React 的应用程序。它包括 React 路由器。在我的一个组件中,我需要读取查询字符串,如果查询字符串参数有值,则有条件地显示一个块。如果查询字符串中不存在该值,我想显示另一个块。
import React, {Component} from 'react';
import {Container} from 'reactstrap';
import {NavMenu} from './NavMenu';
export class Layout extends Component {
static displayName = Layout.name;
render() {
return {
<div>
<NavMenu /> <!-- I want to hide this is query string has hideNav=true -->
<Container> <!-- I want to use a fluid layout if the query string has hideNav=true -->
{this.prop.children}
</Container>
</div>
}
}
}
如何根据查询字符串值有条件地呈现内容。
【问题讨论】:
标签: reactjs