diff --git a/CHANGE.md b/CHANGE.md
index ae0184a..a03f293 100644
--- a/CHANGE.md
+++ b/CHANGE.md
@@ -17,4 +17,6 @@ class 改为了 className
### Progress (名称有警告)
新增 on-status-change 事件
### Upload
-父级不能 computed Upload 的 fileList 了
\ No newline at end of file
+父级不能 computed Upload 的 fileList 了
+### Collapse
+废弃 activeKey,使用 v-model,key 是保留的,更名为 name
\ No newline at end of file
diff --git a/src/components/collapse/collapse.vue b/src/components/collapse/collapse.vue
index 2fd163d..0b6125d 100644
--- a/src/components/collapse/collapse.vue
+++ b/src/components/collapse/collapse.vue
@@ -12,16 +12,21 @@
type: Boolean,
default: false
},
- activeKey: {
+ value: {
type: [Array, String]
}
},
+ data () {
+ return {
+ currentValue: this.value
+ };
+ },
computed: {
classes () {
return `${prefixCls}`;
}
},
- compiled () {
+ mounted () {
this.setActive();
},
methods: {
@@ -29,13 +34,13 @@
const activeKey = this.getActiveKey();
this.$children.forEach((child, index) => {
- const key = child.key || index.toString();
+ const name = child.name || index.toString();
let isActive = false;
if (self.accordion) {
- isActive = activeKey === key;
+ isActive = activeKey === name;
} else {
- isActive = activeKey.indexOf(key) > -1;
+ isActive = activeKey.indexOf(name) > -1;
}
child.isActive = isActive;
@@ -43,7 +48,7 @@
});
},
getActiveKey () {
- let activeKey = this.activeKey || [];
+ let activeKey = this.currentValue || [];
const accordion = this.accordion;
if (!Array.isArray(activeKey)) {
@@ -61,36 +66,40 @@
return activeKey;
},
toggle (data) {
- const key = data.key.toString();
+ const name = data.name.toString();
let newActiveKey = [];
if (this.accordion) {
if (!data.isActive) {
- newActiveKey.push(key);
+ newActiveKey.push(name);
}
} else {
let activeKey = this.getActiveKey();
- const keyIndex = activeKey.indexOf(key);
+ const nameIndex = activeKey.indexOf(name);
if (data.isActive) {
- if (keyIndex > -1) {
- activeKey.splice(keyIndex, 1);
+ if (nameIndex > -1) {
+ activeKey.splice(nameIndex, 1);
}
} else {
- if (keyIndex < 0) {
- activeKey.push(key);
+ if (nameIndex < 0) {
+ activeKey.push(name);
}
}
newActiveKey = activeKey;
}
- this.activeKey = newActiveKey;
+ this.currentValue = newActiveKey;
+ this.$emit('input', newActiveKey);
this.$emit('on-change', newActiveKey);
}
},
watch: {
- activeKey () {
+ value (val) {
+ this.currentValue = val;
+ },
+ currentValue () {
this.setActive();
}
}
diff --git a/src/components/collapse/panel.vue b/src/components/collapse/panel.vue
index bcfc94f..fee3ca0 100644
--- a/src/components/collapse/panel.vue
+++ b/src/components/collapse/panel.vue
@@ -4,7 +4,7 @@
史蒂夫·乔布斯(Steve Jobs),1955年2月24日生于美国加利福尼亚州旧金山,美国发明家、企业家、美国苹果公司联合创办人。
+斯蒂夫·盖瑞·沃兹尼亚克(Stephen Gary Wozniak),美国电脑工程师,曾与史蒂夫·乔布斯合伙创立苹果电脑(今之苹果公司)。斯蒂夫·盖瑞·沃兹尼亚克曾就读于美国科罗拉多大学,后转学入美国著名高等学府加州大学伯克利分校(UC Berkeley)并获得电机工程及计算机(EECS)本科学位(1987年)。
+乔纳森·伊夫是一位工业设计师,现任Apple公司设计师兼资深副总裁,英国爵士。他曾参与设计了iPod,iMac,iPhone,iPad等众多苹果产品。除了乔布斯,他是对苹果那些著名的产品最有影响力的人。
+