Rerendering MDL drawer menu makes drawer button disappear

本小妞迷上赌 提交于 2019-12-08 02:32:26

问题


I'm integrating MDL into a React application.

I've just tried to make a component out of a Fixed Header layout (http://www.getmdl.io/components/index.html#layout-section) and noticed that if I hardcode the layout in the html it works as expected. However if i generate that html at runtime with JS the hamburger icon is missing.

What should I do to fix that problem?


回答1:


When you add an element after dom is already loaded you'll need to 'upgrade' the element. To do so dom-wide, try this snippet

componentHandler.upgradeDom();

exact issue from the mdlhut




回答2:


I have a similar problem. It seems that in this case need to re-create layout. https://github.com/google/material-design-lite/blob/master/src/layout/layout.js#L286



来源:https://stackoverflow.com/questions/31296803/rerendering-mdl-drawer-menu-makes-drawer-button-disappear

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!