New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
imporve the user experience of the official site #4457
Conversation
@pinggod, thanks for your PR! By analyzing the history of the files in this pull request, we identified @benjycui, @afc163 and @waywardmonkeys to be potential reviewers. |
const menu = [ | ||
<Button className="lang" type="ghost" size="small" onClick={this.handleLangChange} key="lang"> | ||
<FormattedMessage id="app.header.lang" /> | ||
</Button>, | ||
<Menu mode={menuMode} selectedKeys={[activeMenuItem]} id="nav" key="nav"> | ||
<Menu.Item key="home"> | ||
<Link to={utils.getLocalizedPathname('/', isZhCN)}> | ||
<Link onClick={this.handleHideMenu} to={utils.getLocalizedPathname('/', isZhCN)}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这样绑定貌似略多余,试试监听 url 变化如何?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嗯嗯 我明天试一下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bisheng 把 browserHistory 封装起来了,用这种方法监听吧: https://github.com/ant-design/ant-design/blob/master/site/theme/template/Layout/index.jsx#L41
@@ -22,7 +24,9 @@ export default class Header extends React.Component { | |||
require('enquire.js') | |||
.register('only screen and (min-width: 320px) and (max-width: 1024px)', { | |||
match: () => { | |||
this.setState({ menuMode: 'inline' }); | |||
this.setState({ menuMode: 'inline' }, () => { | |||
this.context.router.listen(this.handleHideMenu); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果用户不断的 resize 浏览器,match
方法会反复执行的,这样你就监听同一个事件多次了。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是否有方式可以取消监听?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
componentDidMount 里面监听不可以么?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在 componentDidMount 中监听可以实现,只是纯粹的想了解一下是否有取消监听的方式。
这个还有什么需要修改的吗? |
Close: #4302