diff --git a/docs/tabs/examples/demo.md b/docs/tabs/examples/demo.md index fa250da9..4f2de33f 100644 --- a/docs/tabs/examples/demo.md +++ b/docs/tabs/examples/demo.md @@ -89,13 +89,12 @@ layui.use(function() { title: 'New Tab '+ n, // 此处加 n 仅为演示区分,实际应用不需要 content: 'New Tab Content '+ n, id: 'new-'+ n, - aaa: 'attr-'+ n, // 自定义属性,其中 aaa 可任意命名 - done: function(params) { - console.log(params); // 查看返回的参数 + done: function(data) { + console.log(data); // 查看返回的参数 // 给新标签头添加上下文菜单 dropdown.render($.extend({}, dropdownInst.config, { - elem: params.thisHeaderItem // 当前标签头元素 + elem: data.headerItem // 新标签头元素 --- headerItem 为 2.11.2 新增 })); } }, opts); diff --git a/docs/tabs/index.md b/docs/tabs/index.md index ba3e4e4c..d8d476b0 100644 --- a/docs/tabs/index.md +++ b/docs/tabs/index.md @@ -122,6 +122,12 @@ tabs.render({ tabs.add('test', { title: 'New Tab 1', content: 'New Tab Content 1', + done: function(data) { + console.log(data); // 标签相关数据 + + // 为新标签头添加任意属性 + data.headerItem.attr('lay-tips', '111'); + } }); ``` @@ -202,10 +208,10 @@ console.log(data); { options, // 标签配置信息 container, // 标签容器的相关元素 - thisHeaderItem, // 当前标签头部项 - thisBodyItem, // 当前标签内容项 - index, // 当前标签索引 - length, // 当前标签数 + thisHeaderItem, // 当前活动标签头部项 + thisBodyItem, // 当前活动标签内容项 + index, // 当前活动标签索引 + length, // 标签数量 } ``` @@ -228,12 +234,13 @@ var headerItem = tabs.getHeaderItem('test', 'abc'); // 获取 lay-id="abc" 的 `tabs.getBodyItem(id, index)` - 参数 `id` : 组件的实例 ID -- 参数 `index` : 标签索引 +- 参数 `index` : 标签索引或标签的 `lay-id` 属性值 2.11.2+ 该方法用于获取标签内容项元素。 ```js var bodyItem = tabs.getBodyItem('test', 3); // 获取索引为 3 的标签内容项元素 +var bodyItem = tabs.getBodyItem('test', 'abc'); // 获取 lay-id="abc" 的标签内容项元素 ```

刷新标签视图

diff --git a/examples/tabs.html b/examples/tabs.html index 5a6eff73..631ee9d7 100644 --- a/examples/tabs.html +++ b/examples/tabs.html @@ -167,27 +167,40 @@