diff --git a/src/swipe/README.md b/src/swipe/README.md
index 0e1391465..cd47a909d 100644
--- a/src/swipe/README.md
+++ b/src/swipe/README.md
@@ -161,6 +161,7 @@ Use ref to get swipe instance and call instance methods
| Name | Description | Attribute | Return value |
|------|------|------|------|
| swipeTo | Swipe to target index | index: target index, options: Options | void |
+| resize | Resize swipe when container element resized | - | void |
### swipeTo Options
diff --git a/src/swipe/README.zh-CN.md b/src/swipe/README.zh-CN.md
index 8398fe427..aaa4212a1 100644
--- a/src/swipe/README.zh-CN.md
+++ b/src/swipe/README.zh-CN.md
@@ -166,7 +166,8 @@ export default {
| 方法名 | 说明 | 参数 | 返回值 |
|------|------|------|------|
-| swipeTo | 滚动到目标位置 | index: 目标位置的索引, options: 选项 | void |
+| swipeTo | 滚动到目标位置 | index: number, options: Options | void |
+| resize | 外层元素大小变化后,可以调用此方法来触发重绘 | - | void |
### swipeTo Options 格式
diff --git a/src/swipe/index.js b/src/swipe/index.js
index 5d076f5a6..788f04b1e 100644
--- a/src/swipe/index.js
+++ b/src/swipe/index.js
@@ -11,7 +11,7 @@ export default createComponent({
mixins: [
TouchMixin,
BindEventMixin(function(bind, isBind) {
- bind(window, 'resize', this.onResize, true);
+ bind(window, 'resize', this.resize, true);
if (isBind) {
this.initialize();
@@ -154,7 +154,8 @@ export default createComponent({
this.autoPlay();
},
- onResize() {
+ // @exposed-api
+ resize() {
this.initialize(this.activeIndicator);
},
@@ -252,6 +253,7 @@ export default createComponent({
}
},
+ // @exposed-api
swipeTo(index, options = {}) {
this.swiping = true;
this.resetTouchStatus();
diff --git a/src/swipe/test/index.spec.js b/src/swipe/test/index.spec.js
index 68b2d28cb..d973aa99e 100644
--- a/src/swipe/test/index.spec.js
+++ b/src/swipe/test/index.spec.js
@@ -1,19 +1,19 @@
+import Vue from 'vue';
import Swipe from '..';
import SwipeItem from '../../swipe-item';
import { mount, triggerDrag, later } from '../../../test';
+Vue.use(Swipe);
+Vue.use(SwipeItem);
+
const Component = {
template: `
-
- 1
- 2
- 3
-
+
+ 1
+ 2
+ 3
+
`,
- components: {
- Swipe,
- SwipeItem
- },
props: {
vertical: Boolean,
loop: {