MUI移動端頁面跳轉

來源:互聯網
上載者:User

標籤:lis   func   mui   line   ati   查看   net   pen   tde   

今天整理MUI移動端頁面跳轉的幾種方法和遇到的不同的坑先上設定button、label和a標籤的代碼:<body><button type="button" class="mui-btn" onclick="jumpToDetailView()"id="jumpToDetail">查看企業詳情</button><div class="div"><label class="test" id="test">this is a test label</label><a class="atest" id="at">this is a test</a></div></body>跳轉方法一:button類型使用onclick=‘‘,函數跳轉function jumpToDetailView(){alert(‘123‘);mui.openWindow({url:‘details/detail.html‘,id:‘detail.html‘});}這種方法貌似只對button有效,在驗證函式時,alert驗證有效且不影響函數
跳轉方法二:添加監聽事件跳轉document.getElementById(‘at‘).addEventListener(‘tap‘,function(){//alert(‘test a‘);mui.openWindow({url:‘details/detail.html‘,id:‘detail.html‘});});添加監聽事件對所有跳轉都有效,但是在驗證的過程中,使用了alert以後發現彈出框不顯示且跳轉不起作用,不知道具體什麼原因,等以後找到原因再補充。跳轉方法三:使用.on形式跳轉基於官網(http://dev.dcloud.net.cn/mui/event/#on)上的描述“除了可以使用addEventListener()方法監聽某個特定元素上的事件外, 也可以使用.on()方法實現批量元素的事件綁定”。參考範例:mui(".mui-table-view").on(‘tap‘,‘.mui-table-view-cell‘,function(){ //擷取id var id = this.getAttribute("id"); //傳值給詳情頁面,通知載入新資料 mui.fire(detail,‘getDetail‘,{id:id}); //開啟新聞詳情 mui.openWindow({ id:‘detail‘, url:‘detail.html‘ });})以下是本寶寶的一些失敗的例子,希望好心人士看到能指出問題所在。不過我也不會放棄的,如果找到了正確方法我會及時更新的。在這裡先自我檢討一下。//label使用.on形式跳轉// mui(‘.test‘).on(‘tap‘,function(e){// //alert(‘test label‘);// mui.openWindow({// url:‘details/detail.html‘,// id:‘detail.html‘// });// });// mui(‘#test‘).on(‘tap‘,function(e){// //alert(‘test label‘);// mui.openWindow({// url:‘details/detail.html‘,// id:‘detail.html‘// });// });//a標籤使用.on形式跳轉// mui(‘.atest‘).on(‘tap‘,‘a‘,function(e){// //alert(‘test a‘);// mui.openWindow({// url:‘details/detail.html‘,// id:‘detail.html‘// });// });

MUI移動端頁面跳轉

相關關鍵詞:
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.