当我尝试使用下面的代码创建一个实现css moal时,我得到错误.
<script src="~/Scripts/jquery-1.10.2.js"></script> <link href="~/css/materialize.css" rel="stylesheet" /> <script src="~/js/materialize.js"></script> <a id="btnReset" class="waves-effect waves-light btn modal-trigger" data-target="modal1">Reset</a> <!-- Modal Structure --> <div id="modal1" class="modal"> <div class="modal-content"> <h4>Warning !</h4> <p>Do you really want to reset ?</p> </div> <div class="modal-footer"> <a href="#!" class=" modal-action modal-close waves-effect waves-green btn-flat">Yes</a> <a href="#!" class=" modal-action modal-close waves-effect waves-green btn-flat">No</a> </div> </div> <script> $(document).ready(function () { // the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered $('.modal-trigger').leanModal(); }); </script>
我也试过了this question.
解决方法
也许你正在使用Materialize 0.97.8,它不再支持leanModal(它只是简单地改为模态 – 检查
Materialize Documentation.
我也遇到了这个问题,并使用Materialise 0.97.7解决了这个问题.