切换风格

默认Lavender Sky Flowers Wizard Snow Beige California City Dragon Black London Sunset glow Pink Cloud

5

主题

111

积分

0

精华

用户组 

易积分
120
热心
0
好评
0
QQ
求给类库加个项目标记[复制链接]
发表于 2020-2-14 11:49:59 | 显示全部楼层 |阅读模式
20易积分
加一个标记和取项目标记

  1.     function 菜单(name,eventName){  
  2.         this.名称 = name;
  3.         var 菜单数组 = new Array();
  4.         this.添加菜单项 = function (菜单项标题){
  5.                         if(mui.os.plus){
  6.                                 var item = {title:菜单项标题};
  7.                                 菜单数组.push(item);
  8.                         }else{
  9.                                 var table = document.getElementById(this.名称).getElementsByTagName("ul")[0];
  10.                                 var li = document.createElement('li');
  11.                                 li.className = 'mui-table-view-cell';
  12.                                 li.innerHTML = "<a href="+"'#"+this.名称+"'>"+菜单项标题+"</a>";
  13.                                 table.appendChild(li);                               
  14.                         }                       
  15.         }

  16.         this.清空菜单项 = function (){
  17.                         if(mui.os.plus){
  18.                                 菜单数组.splice(0,菜单数组.length);
  19.                         }else{                       
  20.                                 var table = document.getElementById(this.名称).getElementsByTagName("ul")[0];
  21.                                 while(table.hasChildNodes()){
  22.                                         table.removeChild(table.firstChild);
  23.                                 }
  24.                         }
  25.         }

  26.         this.显示菜单 = function (){
  27.                         if(mui.os.plus){
  28.                                 plus.nativeUI.actionSheet( {cancel:"取消",buttons:菜单数组}, function(e){
  29.                                         if(e.index>0){
  30.                                                 var item = 菜单数组[e.index-1];
  31.                                                 eventName(item.title);//菜单项被单击事件,返回菜单项标题
  32.                                         }else{
  33.                                                 eventName("取消");
  34.                                         }
  35.                                 });
  36.                         }else{                       
  37.                                 mui('#'+this.名称).popover('show');
  38.                         }
  39.         }

  40.         this.隐藏菜单 = function (){
  41.                         if(!mui.os.plus){
  42.                                 mui('#'+this.名称).popover('hide');
  43.                         }
  44.         }

  45.         if(eventName!=null){
  46.                         if(!mui.os.plus){
  47.                                 mui('#'+this.名称).on('tap', '.mui-popover-action li>a', function() {
  48.                                         mui('#'+name).popover('hide');//隐藏菜单
  49.                                         eventName(this.innerText);//菜单项被单击事件,返回菜单项标题
  50.                                 });      
  51.                         }
  52.         }
  53.     }  


复制代码



1212
回复

使用道具 举报

5

主题

111

积分

0

精华

用户组 

易积分
120
热心
0
好评
0
QQ
发表于 2020-2-16 17:26:26 来自手机 | 显示全部楼层
积分就这么多,能做的,不够我再充,要不就红包q130005127
易如意中文编程学习交流论坛有你更精彩~
回复

使用道具 举报

QQ|sitemap|免责声明|RGB颜色对照表|手机版|小黑屋| 易如意 - E4A中文编程学习交流论坛

GMT+8, 2024-4-29 02:01 , Processed in 0.042210 second(s), 30 queries .

Powered by Discuz! X3.4

© 2001-2018 eruyi.cn

返回顶部