This question already has answers here:
How to hide drawer upon user click

(12个答案)


5年前关闭。




我在抽屉里有一组链接。就像这里的导航示例:

http://www.getmdl.io/components/index.html#layout-section/layout

唯一的区别是我的链接不会导致页面刷新(这是使用主干构建的单页面应用程序)。单击链接后如何关闭抽屉?

最佳答案

看起来抽屉上有一个.is-visible类,通过将其删除,抽屉隐藏了。所以(使用jquery)类似这样的东西可以切换抽屉:

$(".mdl-layout__drawer").toggleClass("is-visible")

因此,我需要将其添加到链接的事件处理程序中,或将其放在onClick属性中。

关于material-design-lite - 如何在 Material 设计Lite中隐藏打开的抽屉,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31616145/

10-12 23:35