Browse Source

feat(dropdown): click 回调中传递事件对象 (#2273)

pull/2284/head
morning-star 1 month ago committed by GitHub
parent
commit
6159468f82
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      docs/dropdown/detail/options.md
  2. 2
      src/modules/dropdown.js

3
docs/dropdown/detail/options.md

@ -288,10 +288,11 @@ ready: function(elemPanel, elem){
</div>
```
click: function(data, othis){
click: function(data, othis, event){
console.log(data); // 当前所点击的菜单项对应的数据
console.log(othis); // 当前所点击的菜单项元素对象
console.log(this.elem); // 当前组件绑定的目标元素对象,批量绑定中常用
console.log(event); // 事件对象 2.9.18+
// 若返回 false,则点击选项可不关闭面板 --- 2.8+
/*

2
src/modules/dropdown.js

@ -340,7 +340,7 @@ layui.define(['jquery', 'laytpl', 'lay', 'util'], function(exports){
// 普通菜单项点击后的回调及关闭面板
if((!isChild || isClickAllScope) && data.type !== '-'){
var ret = typeof options.click === 'function'
? options.click(data, othis)
? options.click(data, othis, e)
: null;
ret === false || (isChild || that.remove());

Loading…
Cancel
Save