diff --git a/bin/build-entry.js b/bin/build-entry.js
index 9f2544b2f..4cbd41f8d 100644
--- a/bin/build-entry.js
+++ b/bin/build-entry.js
@@ -14,13 +14,13 @@ const install = function(Vue) {
{{install}}
- // Vue.use(Loading);
+ Vue.use(Loading);
- // Vue.prototype.$msgbox = MessageBox;
- // Vue.prototype.$alert = MessageBox.alert;
- // Vue.prototype.$confirm = MessageBox.confirm;
- // Vue.prototype.$prompt = MessageBox.prompt;
- // Vue.prototype.$notify = Notification;
+ Vue.prototype.$msgbox = MessageBox;
+ Vue.prototype.$alert = MessageBox.alert;
+ Vue.prototype.$confirm = MessageBox.confirm;
+ Vue.prototype.$prompt = MessageBox.prompt;
+ Vue.prototype.$notify = Notification;
};
// auto install
diff --git a/components.json b/components.json
index 3f311394d..6e2acfb95 100644
--- a/components.json
+++ b/components.json
@@ -1,7 +1,4 @@
{
- "group": [
- "./packages/group/index.js"
- ],
"select-dropdown": [
"./packages/select-dropdown/index.js"
],
diff --git a/examples/docs/tabs.md b/examples/docs/tabs.md
index ba2152f07..b2594a79a 100644
--- a/examples/docs/tabs.md
+++ b/examples/docs/tabs.md
@@ -15,8 +15,8 @@
title: '选项卡四',
content: '选项卡四内容'
}],
- activeKey: '3',
- activeKey2: ''
+ activeName: '3',
+ activeName2: ''
}
}
}
@@ -30,7 +30,7 @@
## 基础使用
-
+
选项卡一内容
选项卡二内容
选项卡三内容
@@ -39,7 +39,7 @@
```html
-
+
选项卡一内容
选项卡二内容
选项卡三内容
@@ -77,7 +77,7 @@
选项卡四内容
-{{activeKey2}}
+{{activeName2}}
```html
@@ -113,8 +113,8 @@
|---------- |-------- |---------- |------------- |-------- |
| type | 风格类型 | string | card, border-card | |
| closable | 真实值 | boolean | true, false | false |
-| defaultActiveKey | 如果没有设置 activeKey, 则使用该值 | string | | 第一个面板 |
-| activeKey | 当前选中面板的key | string | | |
+| defaultActiveName | 如果没有设置 activeName, 则使用该值 | string | | 第一个面板 |
+| activeName | 当前选中面板的 name | string | | |
| tab.click | tab 被点击的回调 | string | | |
| tab.remove | tab 被删除的回调 | string | | |
@@ -122,4 +122,4 @@
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---------- |-------- |---------- |------------- |-------- |
| label | 选项卡标题 | string | | |
-| key | 与选项卡activeKey对应的标识符 | string | | 该选项卡在选项卡中的index值,如第一个选项卡则为'1' |
+| name | 与选项卡 activeName 对应的标识符 | string | | 该选项卡在选项卡中的 name 值,如第一个选项卡则为'1' |
diff --git a/packages/tabs/src/tab-pane.vue b/packages/tabs/src/tab-pane.vue
index 888001f66..7f7cc5afc 100644
--- a/packages/tabs/src/tab-pane.vue
+++ b/packages/tabs/src/tab-pane.vue
@@ -7,9 +7,7 @@
type: String,
required: true
},
- key: {
- type: String
- }
+ name: String
},
data() {
@@ -18,7 +16,8 @@
transition: '',
paneStyle: {
position: 'relative'
- }
+ },
+ key: ''
};
},
@@ -28,17 +27,20 @@
}
},
- events: {
- },
-
computed: {
show() {
- return this.$parent.activeKey === this.key;
+ return this.$parent.currentName === this.key;
}
},
watch: {
- '$parent.activeKey'(newValue, oldValue) {
+ name: {
+ immediate: true,
+ handler(val) {
+ this.key = val;
+ }
+ },
+ '$parent.currentName'(newValue, oldValue) {
if (this.key === newValue) {
this.transition = newValue > oldValue ? 'slideInRight' : 'slideInLeft';
}
diff --git a/packages/tabs/src/tab.vue b/packages/tabs/src/tab.vue
index e1a66f45b..ea35ec505 100644
--- a/packages/tabs/src/tab.vue
+++ b/packages/tabs/src/tab.vue
@@ -8,20 +8,23 @@
required: true
},
closable: Boolean
- },
- data() {
- return {
- showClose: false
- };
}
};
- {{tab.label}}
+
+ {{tab.label}}
+
+
+
diff --git a/packages/tabs/src/tabs.vue b/packages/tabs/src/tabs.vue
index ab371f641..1e8b70588 100644
--- a/packages/tabs/src/tabs.vue
+++ b/packages/tabs/src/tabs.vue
@@ -11,12 +11,8 @@
props: {
type: String,
tabPosition: String,
- defaultActiveKey: {
- type: String
- },
- activeKey: {
- type: String
- },
+ defaultActiveName: String,
+ activeName: String,
closable: false,
tabWidth: 0
},
@@ -25,34 +21,22 @@
return {
tabs: [],
children: null,
- activeTab: null
+ activeTab: null,
+ currentName: 0,
+ barStyle: ''
};
},
- computed: {
- barStyle: {
- cache: false,
- get() {
- if (this.type) return {};
- var style = {};
- var offset = 0;
- var tabWidth = 0;
-
- this.tabs.every((tab, index) => {
- let $el = this.$refs.tabs[index].$el;
- if (tab.key !== this.activeKey) {
- offset += $el.clientWidth;
- return true;
- } else {
- tabWidth = $el.clientWidth;
- return false;
- }
- });
-
- style.width = tabWidth + 'px';
- style.transform = `translateX(${offset}px)`;
- return style;
+ watch: {
+ activeName: {
+ immediate: true,
+ handler(val) {
+ this.currentName = val || 0;
}
+ },
+
+ 'currentName'() {
+ this.calcBarStyle();
}
},
@@ -67,27 +51,49 @@
this.tabs.splice(index, 1);
}
- if (tab.key === this.activeKey) {
+ if (tab.key === this.currentName) {
let deleteIndex = this.$children.indexOf(tab);
let nextChild = this.$children[deleteIndex + 1];
let prevChild = this.$children[deleteIndex - 1];
- this.activeKey = nextChild ? nextChild.key : prevChild ? prevChild.key : '-1';
+ this.currentName = nextChild ? nextChild.key : prevChild ? prevChild.key : '-1';
}
this.$emit('tab.remove', tab);
},
handleTabClick(tab) {
- this.activeKey = tab.key;
+ this.currentName = tab.key;
this.$emit('tab.click', tab);
+ },
+ calcBarStyle() {
+ if (this.type) return {};
+ var style = {};
+ var offset = 0;
+ var tabWidth = 0;
+
+ this.tabs.every((tab, index) => {
+ let $el = this.$refs.tabs[index].$el;
+ if (tab.key !== this.currentName) {
+ offset += $el.clientWidth;
+ return true;
+ } else {
+ tabWidth = $el.clientWidth;
+ return false;
+ }
+ });
+
+ style.width = tabWidth + 'px';
+ style.transform = `translateX(${offset}px)`;
+
+ this.barStyle = style;
}
},
- ready() {
- if (!this.activeKey) {
- this.activeKey = this.defaultActiveKey || this.$children[0].key;
+
+ mounted() {
+ if (!this.currentName) {
+ this.currentName = this.defaultActiveName || this.$children[0].key;
}
- this.$children.forEach(tab => {
- this.tabs.push(tab);
- });
+ this.$children.forEach(tab => this.tabs.push(tab));
+ this.$nextTick(() => this.calcBarStyle());
}
};
@@ -97,13 +103,17 @@
diff --git a/src/index.js b/src/index.js
index 9942a5fdb..e6b26d846 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,4 +1,3 @@
-import Group from '../packages/group/index.js';
import SelectDropdown from '../packages/select-dropdown/index.js';
import Pagination from '../packages/pagination/index.js';
import Dialog from '../packages/dialog/index.js';
@@ -52,7 +51,6 @@ import Spinner from '../packages/spinner/index.js';
const install = function(Vue) {
if (install.installed) return;
- Vue.component(Group.name, Group);
Vue.component(SelectDropdown.name, SelectDropdown);
Vue.component(Pagination.name, Pagination);
Vue.component(Dialog.name, Dialog);
@@ -109,14 +107,13 @@ const install = function(Vue) {
Vue.prototype.$notify = Notification;
};
-auto install
+// auto install
if (typeof window !== 'undefined' && window.Vue) {
install(window.Vue);
};
module.exports = {
- install
- Group,
+ install,
SelectDropdown,
Pagination,
Dialog,