0

我正在使用材料设计精简版从教程中创建一个菜单 - https://getmdl.io/components/

这是代码

<div class="mdl-card__actions mdl-card--border">

                        <button id="share-menu" class="mdl-button mdl-button--icon mdl-js-button mdl-js-ripple-effect pull-left">
                            <i class="material-icons">share</i>
                        </button>
                        <ul class="mdl-menu mdl-menu--bottom-left mdl-js-menu mdl-js-ripple-effect"
                            for="share-menu">
                            <li class="mdl-menu__item">Some Action</li>
                            <li class="mdl-menu__item mdl-menu__item--full-bleed-divider">Another Action</li>
                            <li disabled class="mdl-menu__item">Disabled Action</li>
                            <li class="mdl-menu__item">Yet Another Action</li>
                        </ul>
                        <span class="mdl-chip mdl-chip--contact center-block">
                            <span class="mdl-chip__contact mdl-color--teal mdl-color-text--white">12</span>
                            <button class="mdl-button mdl-button--icon mdl-button--colored"><i class="material-icons">thumb_up</i></button>
                        </span>
                        <button class="mdl-button mdl-button--icon mdl-button--colored pull-right"><i class="material-icons">add_shopping_cart</i></button>
                    </div>

单击共享按钮时,菜单未创建这里是设计的图像

分享菜单

4

1 回答 1

0

将“ul”元素的“for”属性替换为“data-mdl-for”应该可以解决问题。

试试下面的代码

<div class="mdl-card__actions mdl-card--border">

                    <button id="share-menu" class="mdl-button mdl-button--icon mdl-js-button mdl-js-ripple-effect pull-left">
                        <i class="material-icons">share</i>
                    </button>
                    <ul class="mdl-menu mdl-menu--bottom-left mdl-js-menu mdl-js-ripple-effect"
                        data-mdl-for="share-menu">
                        <li class="mdl-menu__item">Some Action</li>
                        <li class="mdl-menu__item mdl-menu__item--full-bleed-divider">Another Action</li>
                        <li disabled class="mdl-menu__item">Disabled Action</li>
                        <li class="mdl-menu__item">Yet Another Action</li>
                    </ul>
                    <span class="mdl-chip mdl-chip--contact center-block">
                        <span class="mdl-chip__contact mdl-color--teal mdl-color-text--white">12</span>
                        <button class="mdl-button mdl-button--icon mdl-button--colored"><i class="material-icons">thumb_up</i></button>
                    </span>
                    <button class="mdl-button mdl-button--icon mdl-button--colored pull-right"><i class="material-icons">add_shopping_cart</i></button>
                </div>

希望这可以帮助

于 2017-07-19T08:41:36.787 回答