|
|
@ -41,221 +41,282 @@ layui.use('dropdown', function(){ |
|
|
|
var dropdown = layui.dropdown; |
|
|
|
var dropdown = layui.dropdown; |
|
|
|
|
|
|
|
|
|
|
|
dropdown.render({ |
|
|
|
dropdown.render({ |
|
|
|
elem: '#demo1' |
|
|
|
elem: '#demo1', |
|
|
|
,shade: [0.1, '#ddd'] |
|
|
|
shade: [0.1, '#ddd'], |
|
|
|
//,align: 'right' |
|
|
|
//,align: 'right' |
|
|
|
,data: [{ |
|
|
|
data: [ |
|
|
|
title: 'menu item 1' |
|
|
|
{ |
|
|
|
,templet: '<i class="layui-icon layui-icon-light"></i> {{= d.title }} <span class="layui-badge-dot"></span>' |
|
|
|
title: 'menu item 1', |
|
|
|
,id: '' |
|
|
|
templet: |
|
|
|
,href: '' |
|
|
|
'<i class="layui-icon layui-icon-light"></i> {{= d.title }} <span class="layui-badge-dot"></span>', |
|
|
|
,type: '' //菜单类型,支持:normal/group/parent |
|
|
|
id: '', |
|
|
|
},{ |
|
|
|
href: '', |
|
|
|
title: 'menu item <strong>2</strong>' |
|
|
|
type: '' //菜单类型,支持:normal/group/parent |
|
|
|
,templet: '<img src="https://unpkg.com/outeres@0.1.1/demo/avatar/0.png" style="width: 16px;"> {{- d.title }}' |
|
|
|
}, |
|
|
|
,id: '' |
|
|
|
{ |
|
|
|
,href: 'https://www.layui.com/' |
|
|
|
title: 'menu item <strong>2</strong>', |
|
|
|
,target: '_blank' |
|
|
|
templet: |
|
|
|
},{type: '-'},{},{ |
|
|
|
'<img src="https://unpkg.com/outeres@0.1.1/demo/avatar/0.png" style="width: 16px;"> {{- d.title }}', |
|
|
|
title: 'menu item 3 <hello>' |
|
|
|
id: '', |
|
|
|
,id: '' |
|
|
|
href: 'https://www.layui.com/', |
|
|
|
,type: 'group' |
|
|
|
target: '_blank' |
|
|
|
,child: [{ |
|
|
|
}, |
|
|
|
title: 'menu item 3-1' |
|
|
|
{ type: '-' }, |
|
|
|
,id: '' |
|
|
|
{}, |
|
|
|
},{ |
|
|
|
{ |
|
|
|
title: 'menu item 3-2' |
|
|
|
title: 'menu item 3 <hello>', |
|
|
|
,id: '' |
|
|
|
id: '', |
|
|
|
,child: [{ |
|
|
|
type: 'group', |
|
|
|
title: 'menu item 3-2-1' |
|
|
|
child: [ |
|
|
|
,id: '' |
|
|
|
{ |
|
|
|
},{ |
|
|
|
title: 'menu item 3-1', |
|
|
|
title: 'menu item 3-2-2' |
|
|
|
id: '' |
|
|
|
,id: '' |
|
|
|
}, |
|
|
|
,type: 'group' |
|
|
|
{ |
|
|
|
,child: [{ |
|
|
|
title: 'menu item 3-2', |
|
|
|
title: 'menu item 3-2-2-1' |
|
|
|
id: '', |
|
|
|
,id: '' |
|
|
|
child: [ |
|
|
|
},{ |
|
|
|
{ |
|
|
|
title: 'menu item 3-2-2-2' |
|
|
|
title: 'menu item 3-2-1', |
|
|
|
,id: '' |
|
|
|
id: '' |
|
|
|
}] |
|
|
|
}, |
|
|
|
},{ |
|
|
|
{ |
|
|
|
title: 'menu item 3-2-3' |
|
|
|
title: 'menu item 3-2-2', |
|
|
|
,id: '' |
|
|
|
id: '', |
|
|
|
}] |
|
|
|
type: 'group', |
|
|
|
},{ |
|
|
|
child: [ |
|
|
|
title: 'menu item 3-3' |
|
|
|
{ |
|
|
|
,id: '' |
|
|
|
title: 'menu item 3-2-2-1', |
|
|
|
,type: 'group' |
|
|
|
id: '' |
|
|
|
,child: [{ |
|
|
|
}, |
|
|
|
title: 'menu item 3-3-1' |
|
|
|
{ |
|
|
|
,id: '' |
|
|
|
title: 'menu item 3-2-2-2', |
|
|
|
},{ |
|
|
|
id: '' |
|
|
|
title: 'menu item 3-3-2' |
|
|
|
|
|
|
|
,id: '' |
|
|
|
|
|
|
|
,child: [{ |
|
|
|
|
|
|
|
title: 'menu item 3-3-2-1' |
|
|
|
|
|
|
|
,id: '' |
|
|
|
|
|
|
|
},{ |
|
|
|
|
|
|
|
title: 'menu item 3-3-2-2' |
|
|
|
|
|
|
|
,id: '' |
|
|
|
|
|
|
|
},{ |
|
|
|
|
|
|
|
title: 'menu item 3-3-2-3' |
|
|
|
|
|
|
|
,id: '' |
|
|
|
|
|
|
|
}] |
|
|
|
|
|
|
|
},{ |
|
|
|
|
|
|
|
title: 'menu item 3-3-3' |
|
|
|
|
|
|
|
,id: '' |
|
|
|
|
|
|
|
}] |
|
|
|
|
|
|
|
}] |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
,{type: '-'} |
|
|
|
] |
|
|
|
,{ |
|
|
|
}, |
|
|
|
title: 'menu item 4' |
|
|
|
{ |
|
|
|
,id: '' |
|
|
|
title: 'menu item 3-2-3', |
|
|
|
},{ |
|
|
|
id: '' |
|
|
|
title: 'menu item 5' |
|
|
|
} |
|
|
|
,id: '' |
|
|
|
] |
|
|
|
,child: [{ |
|
|
|
}, |
|
|
|
title: 'menu item 5-1' |
|
|
|
{ |
|
|
|
,id: '' |
|
|
|
title: 'menu item 3-3', |
|
|
|
,child: [{ |
|
|
|
id: '', |
|
|
|
title: 'menu item 5-1-1' |
|
|
|
type: 'group', |
|
|
|
,id: '' |
|
|
|
child: [ |
|
|
|
},{ |
|
|
|
{ |
|
|
|
title: 'menu item 5-1-2' |
|
|
|
title: 'menu item 3-3-1', |
|
|
|
,id: '' |
|
|
|
id: '' |
|
|
|
},{ |
|
|
|
}, |
|
|
|
title: 'menu item 5-1-3' |
|
|
|
{ |
|
|
|
,id: '' |
|
|
|
title: 'menu item 3-3-2', |
|
|
|
}] |
|
|
|
id: '', |
|
|
|
},{ |
|
|
|
child: [ |
|
|
|
title: 'menu item 5-2' |
|
|
|
{ |
|
|
|
,id: '' |
|
|
|
title: 'menu item 3-3-2-1', |
|
|
|
},{ |
|
|
|
id: '' |
|
|
|
title: 'menu item 5-3' |
|
|
|
}, |
|
|
|
,id: '' |
|
|
|
{ |
|
|
|
}] |
|
|
|
title: 'menu item 3-3-2-2', |
|
|
|
},{type:'-'},{ |
|
|
|
id: '' |
|
|
|
title: 'menu item 6' |
|
|
|
}, |
|
|
|
,id: '' |
|
|
|
{ |
|
|
|
,type: 'group' |
|
|
|
title: 'menu item 3-3-2-3', |
|
|
|
,isSpreadItem: false |
|
|
|
id: '' |
|
|
|
,child: [{ |
|
|
|
} |
|
|
|
title: 'menu item 6-1' |
|
|
|
] |
|
|
|
,id: '' |
|
|
|
}, |
|
|
|
},{ |
|
|
|
{ |
|
|
|
title: 'menu item 6-2' |
|
|
|
title: 'menu item 3-3-3', |
|
|
|
,id: '' |
|
|
|
id: '' |
|
|
|
},{ |
|
|
|
} |
|
|
|
title: 'menu item 6-3' |
|
|
|
] |
|
|
|
,id: '' |
|
|
|
} |
|
|
|
}] |
|
|
|
] |
|
|
|
}] |
|
|
|
}, |
|
|
|
|
|
|
|
{ type: '-' }, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
title: 'menu item 4', |
|
|
|
|
|
|
|
id: '' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
title: 'menu item 5', |
|
|
|
|
|
|
|
id: '', |
|
|
|
|
|
|
|
child: [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
title: 'menu item 5-1', |
|
|
|
|
|
|
|
id: '', |
|
|
|
|
|
|
|
child: [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
title: 'menu item 5-1-1', |
|
|
|
|
|
|
|
id: '' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
title: 'menu item 5-1-2', |
|
|
|
|
|
|
|
id: '' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
title: 'menu item 5-1-3', |
|
|
|
|
|
|
|
id: '' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
title: 'menu item 5-2', |
|
|
|
|
|
|
|
id: '' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
title: 'menu item 5-3', |
|
|
|
|
|
|
|
id: '' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ type: '-' }, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
title: 'menu item 6', |
|
|
|
|
|
|
|
id: '', |
|
|
|
|
|
|
|
type: 'group', |
|
|
|
|
|
|
|
isSpreadItem: false, |
|
|
|
|
|
|
|
child: [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
title: 'menu item 6-1', |
|
|
|
|
|
|
|
id: '' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
title: 'menu item 6-2', |
|
|
|
|
|
|
|
id: '' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
title: 'menu item 6-3', |
|
|
|
|
|
|
|
id: '' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
|
|
|
|
,id: 'demo1' |
|
|
|
id: 'demo1', |
|
|
|
|
|
|
|
|
|
|
|
// 触发点击事件的元素范围 --- default: 仅子菜单触发点击事件(默认,可不填); all: 所有父子菜单均触发点击事件 |
|
|
|
// 触发点击事件的元素范围 --- default: 仅子菜单触发点击事件(默认,可不填); all: 所有父子菜单均触发点击事件 |
|
|
|
,clickScope: 'all' |
|
|
|
clickScope: 'all', |
|
|
|
|
|
|
|
|
|
|
|
// 菜单被点击的事件 |
|
|
|
// 菜单被点击的事件 |
|
|
|
,click: function(obj){ |
|
|
|
click: function (obj) { |
|
|
|
console.log(obj); |
|
|
|
console.log(obj); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
var inst = dropdown.render({ |
|
|
|
var inst = dropdown.render({ |
|
|
|
elem: '#demo2' |
|
|
|
elem: '#demo2', |
|
|
|
// ,show: true |
|
|
|
// ,show: true |
|
|
|
,data: [{ |
|
|
|
data: [ |
|
|
|
title: 'menu item 1' |
|
|
|
{ |
|
|
|
,href: '#1' |
|
|
|
title: 'menu item 1', |
|
|
|
,disabled: true |
|
|
|
href: '#1', |
|
|
|
},{ |
|
|
|
disabled: true |
|
|
|
title: 'menu item 2(点击不关闭)' |
|
|
|
}, |
|
|
|
,href: '#2' |
|
|
|
{ |
|
|
|
,id: 'bbb' |
|
|
|
title: 'menu item 2(点击不关闭)', |
|
|
|
},{ |
|
|
|
href: '#2', |
|
|
|
title: 'menu item 3' |
|
|
|
id: 'bbb' |
|
|
|
,href: '#3' |
|
|
|
}, |
|
|
|
}] |
|
|
|
{ |
|
|
|
,click: function(data, othis){ |
|
|
|
title: 'menu item 3', |
|
|
|
|
|
|
|
href: '#3' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
click: function (data, othis) { |
|
|
|
console.log(data); |
|
|
|
console.log(data); |
|
|
|
if (data.id === 'bbb') { |
|
|
|
if (data.id === 'bbb') { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
,ready: function(){ |
|
|
|
ready: function () { |
|
|
|
console.log(arguments); |
|
|
|
console.log(arguments); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
close: function () { |
|
|
|
|
|
|
|
console.log('demo2', this.elem); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dropdown.render({ |
|
|
|
dropdown.render({ |
|
|
|
elem: '#demo3' |
|
|
|
elem: '#demo3', |
|
|
|
,content: '自定义内容 123 ' |
|
|
|
content: '自定义内容 123 ', |
|
|
|
,style: 'background:#666;color:#fff;padding:15px;' |
|
|
|
style: 'background:#666;color:#fff;padding:15px;', |
|
|
|
,align: 'center' |
|
|
|
align: 'center', |
|
|
|
,trigger: 'hover' |
|
|
|
trigger: 'hover', |
|
|
|
|
|
|
|
close: function () { |
|
|
|
|
|
|
|
console.log('demo3', this.elem); |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//右键 |
|
|
|
//右键 |
|
|
|
dropdown.render({ |
|
|
|
dropdown.render({ |
|
|
|
elem: document//'#demo20' //也可绑定到 document,从而重置整个右键 |
|
|
|
elem: document, //'#demo20' //也可绑定到 document,从而重置整个右键 |
|
|
|
,trigger: 'contextmenu' //contextmenu |
|
|
|
trigger: 'contextmenu', //contextmenu |
|
|
|
,isAllowSpread: false |
|
|
|
isAllowSpread: false, |
|
|
|
//,style: 'width: 200px' |
|
|
|
//,style: 'width: 200px' |
|
|
|
,customName: { |
|
|
|
customName: { |
|
|
|
children: 'children' |
|
|
|
children: 'children' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
data: [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
title: 'menu item 1', |
|
|
|
|
|
|
|
id: '#1' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
title: 'menu item 2', |
|
|
|
|
|
|
|
id: 'reload' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ type: '-' }, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
title: 'menu item 3', |
|
|
|
|
|
|
|
id: '#3', |
|
|
|
|
|
|
|
children: [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
title: 'menu item 3-1', |
|
|
|
|
|
|
|
id: '#1' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
title: 'menu item 3-2', |
|
|
|
|
|
|
|
id: '#2' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
title: 'menu item 3-3', |
|
|
|
|
|
|
|
id: '#3' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ type: '-' }, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
title: 'menu item 4', |
|
|
|
|
|
|
|
id: '' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
title: 'menu item 5', |
|
|
|
|
|
|
|
id: '#1' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
title: 'menu item 6', |
|
|
|
|
|
|
|
id: '#1' |
|
|
|
} |
|
|
|
} |
|
|
|
,data: [{ |
|
|
|
], |
|
|
|
title: 'menu item 1' |
|
|
|
click: function (obj, othis) { |
|
|
|
,id: '#1' |
|
|
|
|
|
|
|
},{ |
|
|
|
|
|
|
|
title: 'menu item 2' |
|
|
|
|
|
|
|
,id: 'reload' |
|
|
|
|
|
|
|
},{type:'-'},{ |
|
|
|
|
|
|
|
title: 'menu item 3' |
|
|
|
|
|
|
|
,id: '#3' |
|
|
|
|
|
|
|
,children: [{ |
|
|
|
|
|
|
|
title: 'menu item 3-1' |
|
|
|
|
|
|
|
,id: '#1' |
|
|
|
|
|
|
|
},{ |
|
|
|
|
|
|
|
title: 'menu item 3-2' |
|
|
|
|
|
|
|
,id: '#2' |
|
|
|
|
|
|
|
},{ |
|
|
|
|
|
|
|
title: 'menu item 3-3' |
|
|
|
|
|
|
|
,id: '#3' |
|
|
|
|
|
|
|
}] |
|
|
|
|
|
|
|
},{type:'-'},{ |
|
|
|
|
|
|
|
title: 'menu item 4' |
|
|
|
|
|
|
|
,id: '' |
|
|
|
|
|
|
|
},{ |
|
|
|
|
|
|
|
title: 'menu item 5' |
|
|
|
|
|
|
|
,id: '#1' |
|
|
|
|
|
|
|
},{ |
|
|
|
|
|
|
|
title: 'menu item 6' |
|
|
|
|
|
|
|
,id: '#1' |
|
|
|
|
|
|
|
}] |
|
|
|
|
|
|
|
,click: function(obj, othis){ |
|
|
|
|
|
|
|
if (obj.id === 'reload') { |
|
|
|
if (obj.id === 'reload') { |
|
|
|
location.reload(); |
|
|
|
location.reload(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
dropdown.render({ |
|
|
|
dropdown.render({ |
|
|
|
elem: document |
|
|
|
elem: document, |
|
|
|
,content: '123' |
|
|
|
content: '123' |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
</script> |
|
|
|
</script> |
|
|
|
</body> |
|
|
|
</body> |
|
|
|
</html> |
|
|
|
</html> |
|
|
|