diff --git a/docs/tabs/index.md b/docs/tabs/index.md
index ed9e35ab..a38e3a41 100644
--- a/docs/tabs/index.md
+++ b/docs/tabs/index.md
@@ -110,6 +110,7 @@ tabs.render({
| id | 标签的 `lay-id` 属性值 | string | - |
| index | 活动标签的索引或 `lay-id` 属性值,默认取当前选中标签的索引 | number | - |
| mode | 标签的插入方式。支持以下可选值:
- `append` 插入标签到最后
- `prepend` 插入标签到最前
- `before` 在活动标签前插入
- `after` 在活动标签后插入
| string | `append` |
+| active | 是否将新增项设置为活动标签 | boolean | `true` |
| closable | 标签是否可关闭。初始值取决于 `options.closable` | boolean | `false` |
| headerItem | 自定义标签头部元素,如 `headerItem: ''` | string | - |
| bodyItem | 自定义标签内容元素,如 `bodyItem: ''` | string | - |
diff --git a/src/modules/tabs.js b/src/modules/tabs.js
index 263186fd..c37401fe 100644
--- a/src/modules/tabs.js
+++ b/src/modules/tabs.js
@@ -173,7 +173,8 @@ layui.define('component', function(exports) {
* @param {string} opts.id - 标签的 lay-id 属性值
* @param {string} [opts.index] - 活动标签索引,默认取当前选中标签的索引
* @param {('append'|'prepend'|'after'|'before')} [opts.mode='append'] - 标签插入方式
- * @param {string} [opts.closable] - 标签是否可关闭。初始值取决于 options.closable
+ * @param {boolean} [opts.active] - 是否将新增项设置为活动标签
+ * @param {boolean} [opts.closable] - 标签是否可关闭。初始值取决于 options.closable
* @param {string} [opts.headerItem] - 自定义标签头部元素
* @param {string} [opts.bodyItem] - 自定义标签内容元素
* @param {Function} [opts.done] - 标签添加成功后执行的回调函数
@@ -185,6 +186,11 @@ layui.define('component', function(exports) {
var newHeaderItem = that.renderHeaderItem(opts);
var newBodyItem = that.renderBodyItem(opts);
+ // 选项默认值
+ opts = $.extend({
+ active: true
+ }, opts);
+
// 插入方式
if (/(before|after)/.test(opts.mode)) { // 在活动标签前后插入
var data = that.data();
@@ -202,8 +208,12 @@ layui.define('component', function(exports) {
container.body.elem[mode](newBodyItem);
}
- // 将插入项切换为当前标签
- that.change(newHeaderItem, true);
+ // 是否将新增项设置为活动标签
+ if (opts.active) {
+ that.change(newHeaderItem, true);
+ } else {
+ that.roll('auto');
+ }
// 回调
var params = that.data();