mui实现下拉刷新以及click事件无法响应问题
直接上干货
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"> @Styles.Render("~/Content/css") @Scripts.Render("~/bundles/jquery") @Scripts.Render("~/bundles/mui") <script type="text/javascript"> var hostBaseUrl="@Url.Content("~")"; </script> </head> <body> @if (ViewBag.NavStyle == "NavStyle_01") { <!--图片背景--> <header class="mui-bar mui-bar-nav y-bar-nav"> <a class="mui-action-back mui-pull-left y-bar-nav-left" onclick="javascript:history.back(-1);"> <img src="~/Content/images/left.png" /> </a> <h1 class="mui-title">@ViewBag.Title</h1> <a class="mui-action-back mui-pull-right y-bar-nav-right"> <div> <img src="~/Content/images/more.png" /> <img src="~/Content/images//close.png" /> </div> </a> </header> } else { <!--纯色背景--> <header class="mui-bar mui-bar-nav y-bar-nav-01"> <a class="mui-action-back mui-pull-left y-bar-nav-left" onclick="javascript:history.back(-1);"> <img src="~/Content/images/left.png" /> </a> <h1 class="mui-title">@ViewBag.Title</h1> <a class="mui-action-back mui-pull-right y-bar-nav-right"> <img src="~/Content/images/more.png" style="margin-top:22px" /> </a> </header> } <div id="pullrefresh" class="mui-content mui-scroll-wrapper"> <div class="mui-scroll"> @RenderBody() </div> </div> <script> mui.init({ pullRefresh: { container: '#pullrefresh', down: { style: 'circle', callback: pulldownRefresh } } }); /** * 下拉刷新具体业务实现 */ function pulldownRefresh() { setTimeout(function () { var url = location.href; if (url.indexOf("&time=") != -1) { window.location.href = location.href.split("&time=")[0] + "&time=" + ((new Date()).getTime()); } else { window.location.href = location.href.split("?time=")[0] + "?time=" + ((new Date()).getTime()); } mui('#pullrefresh').pullRefresh().endPulldownToRefresh(); }, 2000); } /** * 这很重要!!!mui框架下拉刷新上拉加载,click事件无效的解决方法 */ mui("#pullrefresh").on("tap", "div,button", function (event) { this.click(); }); </script> @RenderSection("scripts", required: false) </body> </html>