diff --git a/src/cell-group/index.tsx b/src/cell-group/index.tsx
index 6284790d6..7fcaeef32 100644
--- a/src/cell-group/index.tsx
+++ b/src/cell-group/index.tsx
@@ -25,7 +25,7 @@ function CellGroup(
) {
const Group = (
- {slots.default && slots.default()}
+ {slots.default?.()}
);
diff --git a/src/circle/index.js b/src/circle/index.js
index 4a481b871..2c1d2adfa 100644
--- a/src/circle/index.js
+++ b/src/circle/index.js
@@ -152,6 +152,7 @@ export default createComponent({
const now = Date.now();
const progress = Math.min((now - this.startTime) / this.duration, 1);
const rate = progress * (this.endRate - this.startRate) + this.startRate;
+
this.$emit('input', format(parseFloat(rate.toFixed(1))));
if (this.increase ? rate < this.endRate : rate > this.endRate) {
diff --git a/src/collapse-item/index.js b/src/collapse-item/index.js
index e8282affb..a601edbb8 100644
--- a/src/collapse-item/index.js
+++ b/src/collapse-item/index.js
@@ -6,6 +6,7 @@ import { cellProps } from '../cell/shared';
import { ChildrenMixin } from '../mixins/relation';
const [createComponent, bem] = createNamespace('collapse-item');
+
const CELL_SLOTS = ['title', 'icon', 'right-icon'];
export default createComponent({
@@ -40,7 +41,11 @@ export default createComponent({
const { value, accordion } = this.parent;
- if (process.env.NODE_ENV !== 'production' && !accordion && !Array.isArray(value)) {
+ if (
+ process.env.NODE_ENV !== 'production' &&
+ !accordion &&
+ !Array.isArray(value)
+ ) {
console.error('[Vant] Collapse: type of prop "value" should be Array');
return;
}
@@ -73,6 +78,7 @@ export default createComponent({
nextTick(() => {
const { content, wrapper } = this.$refs;
+
if (!content || !wrapper) {
return;
}
@@ -99,9 +105,9 @@ export default createComponent({
return;
}
- const { parent } = this;
- const name =
- parent.accordion && this.currentName === parent.value ? '' : this.currentName;
+ const { parent, currentName } = this;
+ const name = parent.accordion && currentName === parent.value ? '' : currentName;
+
this.parent.switch(name, !this.expanded);
},
@@ -111,52 +117,59 @@ export default createComponent({
} else {
this.$refs.wrapper.style.height = '';
}
+ },
+
+ genTitle() {
+ const { disabled, expanded } = this;
+
+ const titleSlots = CELL_SLOTS.reduce((slots, name) => {
+ if (this.slots(name)) {
+ slots[name] = () => this.slots(name);
+ }
+
+ return slots;
+ }, {});
+
+ if (this.slots('value')) {
+ titleSlots.default = () => this.slots('value');
+ }
+
+ return (
+ |
+ );
+ },
+
+ genContent() {
+ if (this.inited) {
+ return (
+
+ );
+ }
}
},
render() {
- const { disabled, expanded } = this;
-
- const titleSlots = CELL_SLOTS.reduce((slots, name) => {
- if (this.slots(name)) {
- slots[name] = () => this.slots(name);
- }
- return slots;
- }, {});
-
- if (this.slots('value')) {
- titleSlots.default = () => this.slots('value');
- }
-
- const Title = (
- |
- );
-
- const Content = this.inited && (
-
- );
-
return (
- {Title}
- {Content}
+ {this.genTitle()}
+ {this.genContent()}
);
}
diff --git a/src/contact-card/index.tsx b/src/contact-card/index.tsx
index faf71fe18..c5c90d105 100644
--- a/src/contact-card/index.tsx
+++ b/src/contact-card/index.tsx
@@ -30,6 +30,17 @@ function ContactCard(
}
}
+ function Content() {
+ if (type === 'add') {
+ return props.addText || t('addText');
+ }
+
+ return [
+ {`${t('name')}:${props.name}`}
,
+ {`${t('tel')}:${props.tel}`}
+ ];
+ }
+
return (
- {type === 'add'
- ? props.addText || t('addText')
- : [
- {`${t('name')}:${props.name}`} ,
- {`${t('tel')}:${props.tel}`}
- ]}
+ {Content()}
|
);
}