diff --git a/src/swipe-item/index.js b/src/swipe-item/index.js
index 4f6061906..d0e7ba973 100644
--- a/src/swipe-item/index.js
+++ b/src/swipe-item/index.js
@@ -12,17 +12,28 @@ export default createComponent({
};
},
+ computed: {
+ style() {
+ const style = {};
+ const { vertical, computedWidth, computedHeight } = this.parent;
+
+ if (vertical) {
+ style.height = `${computedHeight}px`;
+ } else {
+ style.width = `${computedWidth}px`;
+ }
+
+ if (this.offset) {
+ style.transform = `translate${vertical ? 'Y' : 'X'}(${this.offset}px)`;
+ }
+
+ return style;
+ },
+ },
+
render() {
- const { vertical, computedWidth, computedHeight } = this.parent;
-
- const style = {
- width: computedWidth + 'px',
- height: vertical ? computedHeight + 'px' : '100%',
- transform: `translate${vertical ? 'Y' : 'X'}(${this.offset}px)`,
- };
-
return (
-
+
{this.slots()}
);
diff --git a/src/swipe-item/index.less b/src/swipe-item/index.less
index 2433c7f53..0fdb679e8 100644
--- a/src/swipe-item/index.less
+++ b/src/swipe-item/index.less
@@ -1,6 +1,7 @@
@import '../style/var';
.van-swipe-item {
- float: left;
+ flex-shrink: 0;
+ width: 100%;
height: 100%;
}
diff --git a/src/swipe/index.js b/src/swipe/index.js
index fca882a6c..d754e4a58 100644
--- a/src/swipe/index.js
+++ b/src/swipe/index.js
@@ -382,7 +382,11 @@ export default createComponent({
render() {
return (
-
+
{this.slots()}
{this.genIndicator()}
diff --git a/src/swipe/index.less b/src/swipe/index.less
index 41f10403e..af15d62cb 100644
--- a/src/swipe/index.less
+++ b/src/swipe/index.less
@@ -7,7 +7,12 @@
user-select: none;
&__track {
+ display: flex;
height: 100%;
+
+ &--vertical {
+ flex-direction: column;
+ }
}
&__indicators {
diff --git a/src/swipe/test/__snapshots__/demo.spec.js.snap b/src/swipe/test/__snapshots__/demo.spec.js.snap
index 72a46aabd..799f7af64 100644
--- a/src/swipe/test/__snapshots__/demo.spec.js.snap
+++ b/src/swipe/test/__snapshots__/demo.spec.js.snap
@@ -5,10 +5,10 @@ exports[`renders demo correctly 1`] = `
-
1
-
2
-
3
-
4
+
1
+
2
+
3
+
4
@@ -16,10 +16,10 @@ exports[`renders demo correctly 1`] = `
@@ -27,21 +27,21 @@ exports[`renders demo correctly 1`] = `
-
1
-
2
-
3
-
4
+
1
+
2
+
3
+
4
-
@@ -49,10 +49,10 @@ exports[`renders demo correctly 1`] = `
-
1
-
2
-
3
-
4
+
1
+
2
+
3
+
4
@@ -60,10 +60,10 @@ exports[`renders demo correctly 1`] = `
-
1
-
2
-
3
-
4
+
1
+
2
+
3
+
4
1/4