/*! For license information please see 75.1f39671f.js.LICENSE.txt */ (self.webpackChunk=self.webpackChunk||[]).push([["75"],{2681:function(s,a,n){"use strict";n.r(a);var t=n("80681");let p=["innerHTML"];a.default={setup:()=>({html:""}),render:()=>((0,t.wg)(),(0,t.iD)("div",{class:"van-doc-markdown-body",innerHTML:'

Swipe \u8F6E\u64AD

\n

\u4ECB\u7ECD

\n

\u7528\u4E8E\u5FAA\u73AF\u64AD\u653E\u4E00\u7EC4\u56FE\u7247\u6216\u5185\u5BB9\u3002

\n

\u5F15\u5165

\n

\u901A\u8FC7\u4EE5\u4E0B\u65B9\u5F0F\u6765\u5168\u5C40\u6CE8\u518C\u7EC4\u4EF6\uFF0C\u66F4\u591A\u6CE8\u518C\u65B9\u5F0F\u8BF7\u53C2\u8003\u7EC4\u4EF6\u6CE8\u518C\u3002

\n
import { createApp } from 'vue';\nimport { Swipe, SwipeItem } from 'vant';\n\nconst app = createApp();\napp.use(Swipe);\napp.use(SwipeItem);\n
\n

\u4EE3\u7801\u6F14\u793A

\n

\u57FA\u7840\u7528\u6CD5

\n

\u6BCF\u4E2A SwipeItem \u4EE3\u8868\u4E00\u5F20\u8F6E\u64AD\u5361\u7247\uFF0C\u53EF\u4EE5\u901A\u8FC7 autoplay \u5C5E\u6027\u8BBE\u7F6E\u81EA\u52A8\u8F6E\u64AD\u7684\u95F4\u9694\u3002

\n
<van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">\n  <van-swipe-item>1</van-swipe-item>\n  <van-swipe-item>2</van-swipe-item>\n  <van-swipe-item>3</van-swipe-item>\n  <van-swipe-item>4</van-swipe-item>\n</van-swipe>\n\n<style>\n  .my-swipe .van-swipe-item {\n    color: #fff;\n    font-size: 20px;\n    line-height: 150px;\n    text-align: center;\n    background-color: #39a9ed;\n  }\n</style>\n
\n

\u61D2\u52A0\u8F7D

\n

\u5F53 Swipe \u4E2D\u542B\u6709\u56FE\u7247\u65F6\uFF0C\u53EF\u4EE5\u901A\u8FC7 lazy-render \u5C5E\u6027\u6765\u5F00\u542F\u61D2\u52A0\u8F7D\u6A21\u5F0F\u3002\u5728\u61D2\u52A0\u8F7D\u6A21\u5F0F\u4E0B\uFF0C\u53EA\u4F1A\u6E32\u67D3\u5F53\u524D\u9875\u548C\u4E0B\u4E00\u9875\u3002

\n
<van-swipe :autoplay="3000" lazy-render>\n  <van-swipe-item v-for="image in images" :key="image">\n    <img :src="image" />\n  </van-swipe-item>\n</van-swipe>\n
\n
export default {\n  setup() {\n    const images = [\n      'https://fastly.jsdelivr.net/npm/@vant/assets/apple-1.jpeg',\n      'https://fastly.jsdelivr.net/npm/@vant/assets/apple-2.jpeg',\n    ];\n    return { images };\n  },\n};\n
\n

\u76D1\u542C change \u4E8B\u4EF6

\n

\u5728\u6BCF\u4E00\u9875\u8F6E\u64AD\u7ED3\u675F\u540E\uFF0C\u4F1A\u89E6\u53D1 change \u4E8B\u4EF6\u3002

\n
<van-swipe @change="onChange">\n  <van-swipe-item>1</van-swipe-item>\n  <van-swipe-item>2</van-swipe-item>\n  <van-swipe-item>3</van-swipe-item>\n  <van-swipe-item>4</van-swipe-item>\n</van-swipe>\n
\n
import { showToast } from 'vant';\n\nexport default {\n  setup() {\n    const onChange = (index) => showToast('\u5F53\u524D Swipe \u7D22\u5F15\uFF1A' + index);\n    return { onChange };\n  },\n};\n
\n

\u7EB5\u5411\u6EDA\u52A8

\n

\u8BBE\u7F6E vertical \u5C5E\u6027\u540E\u6ED1\u5757\u4F1A\u7EB5\u5411\u6392\u5217\uFF0C\u6B64\u65F6\u9700\u8981\u6307\u5B9A\u6ED1\u5757\u5BB9\u5668\u7684\u9AD8\u5EA6\u3002

\n
<van-swipe style="height: 200px;" vertical>\n  <van-swipe-item>1</van-swipe-item>\n  <van-swipe-item>2</van-swipe-item>\n  <van-swipe-item>3</van-swipe-item>\n  <van-swipe-item>4</van-swipe-item>\n</van-swipe>\n
\n

\u81EA\u5B9A\u4E49\u6ED1\u5757\u5927\u5C0F

\n

\u6ED1\u5757\u9ED8\u8BA4\u5BBD\u5EA6\u4E3A 100%\uFF0C\u53EF\u4EE5\u901A\u8FC7 width \u5C5E\u6027\u8BBE\u7F6E\u5355\u4E2A\u6ED1\u5757\u7684\u5BBD\u5EA6\u3002\u7EB5\u5411\u6EDA\u52A8\u6A21\u5F0F\u4E0B\uFF0C\u53EF\u4EE5\u901A\u8FC7 height \u5C5E\u6027\u8BBE\u7F6E\u5355\u4E2A\u6ED1\u5757\u7684\u9AD8\u5EA6\u3002

\n
<van-swipe :loop="false" :width="300">\n  <van-swipe-item>1</van-swipe-item>\n  <van-swipe-item>2</van-swipe-item>\n  <van-swipe-item>3</van-swipe-item>\n  <van-swipe-item>4</van-swipe-item>\n</van-swipe>\n
\n
\n

\u76EE\u524D\u4E0D\u652F\u6301\u5728\u5FAA\u73AF\u6EDA\u52A8\u6A21\u5F0F\u4E0B\u81EA\u5B9A\u4E49\u6ED1\u5757\u5927\u5C0F\uFF0C\u56E0\u6B64\u9700\u8981\u5C06 loop \u8BBE\u7F6E\u4E3A false\u3002

\n
\n

\u81EA\u5B9A\u4E49\u6307\u793A\u5668

\n

\u901A\u8FC7 indicator \u63D2\u69FD\u53EF\u4EE5\u81EA\u5B9A\u4E49\u6307\u793A\u5668\u7684\u6837\u5F0F\u3002

\n
<van-swipe>\n  <van-swipe-item>1</van-swipe-item>\n  <van-swipe-item>2</van-swipe-item>\n  <van-swipe-item>3</van-swipe-item>\n  <van-swipe-item>4</van-swipe-item>\n  <template #indicator="{ active, total }">\n    <div class="custom-indicator">{{ active + 1 }}/{{ total }}</div>\n  </template>\n</van-swipe>\n\n<style>\n  .custom-indicator {\n    position: absolute;\n    right: 5px;\n    bottom: 5px;\n    padding: 2px 5px;\n    font-size: 12px;\n    background: rgba(0, 0, 0, 0.1);\n  }\n</style>\n
\n

API

\n

Swipe Props

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u53C2\u6570\u8BF4\u660E\u7C7B\u578B\u9ED8\u8BA4\u503C
autoplay\u81EA\u52A8\u8F6E\u64AD\u95F4\u9694\uFF0C\u5355\u4F4D\u4E3A msnumber | string-
duration\u52A8\u753B\u65F6\u957F\uFF0C\u5355\u4F4D\u4E3A msnumber | string500
initial-swipe\u521D\u59CB\u4F4D\u7F6E\u7D22\u5F15\u503Cnumber | string0
width\u6ED1\u5757\u5BBD\u5EA6\uFF0C\u5355\u4F4D\u4E3A pxnumber | stringauto
height\u6ED1\u5757\u9AD8\u5EA6\uFF0C\u5355\u4F4D\u4E3A pxnumber | stringauto
loop\u662F\u5426\u5F00\u542F\u5FAA\u73AF\u64AD\u653Ebooleantrue
show-indicators\u662F\u5426\u663E\u793A\u6307\u793A\u5668booleantrue
vertical\u662F\u5426\u4E3A\u7EB5\u5411\u6EDA\u52A8booleanfalse
touchable\u662F\u5426\u53EF\u4EE5\u901A\u8FC7\u624B\u52BF\u6ED1\u52A8booleantrue
stop-propagation\u662F\u5426\u963B\u6B62\u6ED1\u52A8\u4E8B\u4EF6\u5192\u6CE1booleantrue
lazy-render\u662F\u5426\u5EF6\u8FDF\u6E32\u67D3\u672A\u5C55\u793A\u7684\u8F6E\u64ADbooleanfalse
indicator-color\u6307\u793A\u5668\u989C\u8272string#1989fa
\n

Swipe Events

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u4E8B\u4EF6\u540D\u8BF4\u660E\u56DE\u8C03\u53C2\u6570
change\u6BCF\u4E00\u9875\u8F6E\u64AD\u7ED3\u675F\u540E\u89E6\u53D1index: number
drag-start v4.0.9\u5F53\u7528\u6237\u5F00\u59CB\u62D6\u52A8\u8F6E\u64AD\u7EC4\u4EF6\u65F6\u89E6\u53D1{ index: number }
drag-end v4.0.9\u5F53\u7528\u6237\u7ED3\u675F\u62D6\u52A8\u8F6E\u64AD\u7EC4\u4EF6\u65F6\u89E6\u53D1{ index: number }
\n

SwipeItem Events

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u4E8B\u4EF6\u540D\u8BF4\u660E\u56DE\u8C03\u53C2\u6570
click\u70B9\u51FB\u65F6\u89E6\u53D1event: MouseEvent
\n

Swipe \u65B9\u6CD5

\n

\u901A\u8FC7 ref \u53EF\u4EE5\u83B7\u53D6\u5230 Swipe \u5B9E\u4F8B\u5E76\u8C03\u7528\u5B9E\u4F8B\u65B9\u6CD5\uFF0C\u8BE6\u89C1\u7EC4\u4EF6\u5B9E\u4F8B\u65B9\u6CD5\u3002

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u65B9\u6CD5\u540D\u8BF4\u660E\u53C2\u6570\u8FD4\u56DE\u503C
prev\u5207\u6362\u5230\u4E0A\u4E00\u8F6E\u64AD--
next\u5207\u6362\u5230\u4E0B\u4E00\u8F6E\u64AD--
swipeTo\u5207\u6362\u5230\u6307\u5B9A\u4F4D\u7F6Eindex: number, options: SwipeToOptions-
resize\u5916\u5C42\u5143\u7D20\u5927\u5C0F\u6216\u7EC4\u4EF6\u663E\u793A\u72B6\u6001\u53D8\u5316\u65F6\uFF0C\u53EF\u4EE5\u8C03\u7528\u6B64\u65B9\u6CD5\u6765\u89E6\u53D1\u91CD\u7ED8--
\n

\u7C7B\u578B\u5B9A\u4E49

\n

\u7EC4\u4EF6\u5BFC\u51FA\u4EE5\u4E0B\u7C7B\u578B\u5B9A\u4E49\uFF1A

\n
import type { SwipeProps, SwipeInstance, SwipeToOptions } from 'vant';\n
\n

SwipeInstance \u662F\u7EC4\u4EF6\u5B9E\u4F8B\u7684\u7C7B\u578B\uFF0C\u7528\u6CD5\u5982\u4E0B\uFF1A

\n
import { ref } from 'vue';\nimport type { SwipeInstance } from 'vant';\n\nconst swipeRef = ref<SwipeInstance>();\n\nswipeRef.value?.next();\n
\n

SwipeToOptions \u683C\u5F0F

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u540D\u79F0\u8BF4\u660E\u7C7B\u578B
immediate\u662F\u5426\u8DF3\u8FC7\u52A8\u753Bboolean
\n

Swipe Slots

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u540D\u79F0\u8BF4\u660E\u53C2\u6570
default\u8F6E\u64AD\u5185\u5BB9-
indicator\u81EA\u5B9A\u4E49\u6307\u793A\u5668{ active: number, total: number }
\n

\u4E3B\u9898\u5B9A\u5236

\n

\u6837\u5F0F\u53D8\u91CF

\n

\u7EC4\u4EF6\u63D0\u4F9B\u4E86\u4E0B\u5217 CSS \u53D8\u91CF\uFF0C\u53EF\u7528\u4E8E\u81EA\u5B9A\u4E49\u6837\u5F0F\uFF0C\u4F7F\u7528\u65B9\u6CD5\u8BF7\u53C2\u8003 ConfigProvider \u7EC4\u4EF6\u3002

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u540D\u79F0\u9ED8\u8BA4\u503C\u63CF\u8FF0
--van-swipe-indicator-size6px-
--van-swipe-indicator-marginvar(--van-padding-sm)-
--van-swipe-indicator-active-opacity1-
--van-swipe-indicator-inactive-opacity0.3-
--van-swipe-indicator-active-backgroundvar(--van-primary-color)-
--van-swipe-indicator-inactive-backgroundvar(--van-border-color)-
\n

\u5E38\u89C1\u95EE\u9898

\n

\u6ED1\u52A8\u8F6E\u64AD\u65F6\u4E3A\u4EC0\u4E48\u89E6\u53D1\u4E86 click \u4E8B\u4EF6\uFF1F

\n

\u8FD9\u79CD\u60C5\u51B5\u901A\u5E38\u662F\u7531\u4E8E\u9879\u76EE\u4E2D\u5F15\u5165\u4E86 fastclick \u5E93\u5BFC\u81F4\u7684\u3002fastclick \u7684\u539F\u7406\u662F\u901A\u8FC7 Touch \u4E8B\u4EF6\u6A21\u62DF\u51FA click \u4E8B\u4EF6\uFF0C\u800C Swipe \u5185\u90E8\u9ED8\u8BA4\u4F1A\u963B\u6B62 touchmove \u4E8B\u4EF6\u5192\u6CE1\uFF0C\u5E72\u6270\u4E86 fastclick \u7684\u5224\u65AD\uFF0C\u5BFC\u81F4\u51FA\u73B0\u8FD9\u4E2A\u95EE\u9898\u3002

\n

\u5C06 Swipe \u7EC4\u4EF6\u7684 stop-propagation \u5C5E\u6027\u8BBE\u7F6E\u4E3A false \u5373\u53EF\u907F\u514D\u8BE5\u95EE\u9898\u3002

\n

\u5728\u684C\u9762\u7AEF\u65E0\u6CD5\u64CD\u4F5C\u7EC4\u4EF6\uFF1F

\n

\u53C2\u89C1\u684C\u9762\u7AEF\u9002\u914D\u3002

\n

Swipe \u7EC4\u4EF6\u529F\u80FD\u592A\u5C11\uFF0C\u65E0\u6CD5\u5B9E\u73B0\u590D\u6742\u6548\u679C\uFF1F

\n

Vant \u4E2D\u7684 Swipe \u7EC4\u4EF6\u662F\u6BD4\u8F83\u8F7B\u91CF\u7684\uFF0C\u56E0\u6B64\u529F\u80FD\u4E5F\u6BD4\u8F83\u57FA\u7840\u3002\u5982\u679C\u9700\u8981\u66F4\u590D\u6742\u7684\u8F6E\u64AD\u6548\u679C\uFF0C\u63A8\u8350\u4F7F\u7528\u793E\u533A\u91CC\u4E00\u4E9B\u4F18\u8D28\u7684\u8F6E\u64AD\u5E93\uFF0C\u6BD4\u5982 vue-awesome-swiper\u3002

\n

\u7EC4\u4EF6\u4ECE\u9690\u85CF\u72B6\u6001\u5207\u6362\u5230\u663E\u793A\u72B6\u6001\u65F6\uFF0C\u65E0\u6CD5\u6B63\u786E\u6E32\u67D3\uFF1F

\n

Swipe \u7EC4\u4EF6\u5728\u6302\u8F7D\u65F6\uFF0C\u4F1A\u83B7\u53D6\u81EA\u8EAB\u7684\u5BBD\u5EA6\uFF0C\u5E76\u8BA1\u7B97\u51FA\u8F6E\u64AD\u56FE\u7684\u4F4D\u7F6E\u3002\u5982\u679C\u7EC4\u4EF6\u4E00\u5F00\u59CB\u5904\u4E8E\u9690\u85CF\u72B6\u6001\uFF0C\u5219\u83B7\u53D6\u5230\u7684\u5BBD\u5EA6\u6C38\u8FDC\u4E3A 0\uFF0C\u56E0\u6B64\u65E0\u6CD5\u6B63\u786E\u8BA1\u7B97\u4F4D\u7F6E\u3002

\n

\u89E3\u51B3\u65B9\u6CD5

\n

\u65B9\u6CD5\u4E00\uFF0C\u5982\u679C\u662F\u4F7F\u7528 v-show \u6765\u63A7\u5236\u7EC4\u4EF6\u5C55\u793A\u7684\uFF0C\u5219\u66FF\u6362\u4E3A v-if \u5373\u53EF\u89E3\u51B3\u6B64\u95EE\u9898\uFF1A

\n
<!-- Before -->\n<van-swipe v-show="show" />\n<!-- After -->\n<van-swipe v-if="show" />\n
\n

\u65B9\u6CD5\u4E8C\uFF0C\u8C03\u7528\u7EC4\u4EF6\u7684 resize \u65B9\u6CD5\u6765\u4E3B\u52A8\u89E6\u53D1\u91CD\u7ED8\uFF1A

\n
<van-swipe v-show="show" ref="swipe" />\n
\n
this.$refs.swipe.resize();\n
\n
'},null,8,p))}}}]);