/*! 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:'
\u7528\u4E8E\u5FAA\u73AF\u64AD\u653E\u4E00\u7EC4\u56FE\u7247\u6216\u5185\u5BB9\u3002
\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
\nimport { createApp } from 'vue';\nimport { Swipe, SwipeItem } from 'vant';\n\nconst app = createApp();\napp.use(Swipe);\napp.use(SwipeItem);\n
\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
<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\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
<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
\nexport 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\u5728\u6BCF\u4E00\u9875\u8F6E\u64AD\u7ED3\u675F\u540E\uFF0C\u4F1A\u89E6\u53D1 change
\u4E8B\u4EF6\u3002
<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
\nimport { 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\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
<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\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
<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\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
\u901A\u8FC7 indicator
\u63D2\u69FD\u53EF\u4EE5\u81EA\u5B9A\u4E49\u6307\u793A\u5668\u7684\u6837\u5F0F\u3002
<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\u53C2\u6570 | \n\u8BF4\u660E | \n\u7C7B\u578B | \n\u9ED8\u8BA4\u503C | \n
---|---|---|---|
autoplay | \n\u81EA\u52A8\u8F6E\u64AD\u95F4\u9694\uFF0C\u5355\u4F4D\u4E3A ms | \nnumber | string | \n- | \n
duration | \n\u52A8\u753B\u65F6\u957F\uFF0C\u5355\u4F4D\u4E3A ms | \nnumber | string | \n500 | \n
initial-swipe | \n\u521D\u59CB\u4F4D\u7F6E\u7D22\u5F15\u503C | \nnumber | string | \n0 | \n
width | \n\u6ED1\u5757\u5BBD\u5EA6\uFF0C\u5355\u4F4D\u4E3A px | \nnumber | string | \nauto | \n
height | \n\u6ED1\u5757\u9AD8\u5EA6\uFF0C\u5355\u4F4D\u4E3A px | \nnumber | string | \nauto | \n
loop | \n\u662F\u5426\u5F00\u542F\u5FAA\u73AF\u64AD\u653E | \nboolean | \ntrue | \n
show-indicators | \n\u662F\u5426\u663E\u793A\u6307\u793A\u5668 | \nboolean | \ntrue | \n
vertical | \n\u662F\u5426\u4E3A\u7EB5\u5411\u6EDA\u52A8 | \nboolean | \nfalse | \n
touchable | \n\u662F\u5426\u53EF\u4EE5\u901A\u8FC7\u624B\u52BF\u6ED1\u52A8 | \nboolean | \ntrue | \n
stop-propagation | \n\u662F\u5426\u963B\u6B62\u6ED1\u52A8\u4E8B\u4EF6\u5192\u6CE1 | \nboolean | \ntrue | \n
lazy-render | \n\u662F\u5426\u5EF6\u8FDF\u6E32\u67D3\u672A\u5C55\u793A\u7684\u8F6E\u64AD | \nboolean | \nfalse | \n
indicator-color | \n\u6307\u793A\u5668\u989C\u8272 | \nstring | \n#1989fa | \n
\u4E8B\u4EF6\u540D | \n\u8BF4\u660E | \n\u56DE\u8C03\u53C2\u6570 | \n
---|---|---|
change | \n\u6BCF\u4E00\u9875\u8F6E\u64AD\u7ED3\u675F\u540E\u89E6\u53D1 | \nindex: number | \n
drag-start v4.0.9 | \n\u5F53\u7528\u6237\u5F00\u59CB\u62D6\u52A8\u8F6E\u64AD\u7EC4\u4EF6\u65F6\u89E6\u53D1 | \n{ index: number } | \n
drag-end v4.0.9 | \n\u5F53\u7528\u6237\u7ED3\u675F\u62D6\u52A8\u8F6E\u64AD\u7EC4\u4EF6\u65F6\u89E6\u53D1 | \n{ index: number } | \n
\u4E8B\u4EF6\u540D | \n\u8BF4\u660E | \n\u56DE\u8C03\u53C2\u6570 | \n
---|---|---|
click | \n\u70B9\u51FB\u65F6\u89E6\u53D1 | \nevent: MouseEvent | \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\u65B9\u6CD5\u540D | \n\u8BF4\u660E | \n\u53C2\u6570 | \n\u8FD4\u56DE\u503C | \n
---|---|---|---|
prev | \n\u5207\u6362\u5230\u4E0A\u4E00\u8F6E\u64AD | \n- | \n- | \n
next | \n\u5207\u6362\u5230\u4E0B\u4E00\u8F6E\u64AD | \n- | \n- | \n
swipeTo | \n\u5207\u6362\u5230\u6307\u5B9A\u4F4D\u7F6E | \nindex: number, options: SwipeToOptions | \n- | \n
resize | \n\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- | \n- | \n
\u7EC4\u4EF6\u5BFC\u51FA\u4EE5\u4E0B\u7C7B\u578B\u5B9A\u4E49\uFF1A
\nimport type { SwipeProps, SwipeInstance, SwipeToOptions } from 'vant';\n
\nSwipeInstance
\u662F\u7EC4\u4EF6\u5B9E\u4F8B\u7684\u7C7B\u578B\uFF0C\u7528\u6CD5\u5982\u4E0B\uFF1A
import { ref } from 'vue';\nimport type { SwipeInstance } from 'vant';\n\nconst swipeRef = ref<SwipeInstance>();\n\nswipeRef.value?.next();\n
\n\u540D\u79F0 | \n\u8BF4\u660E | \n\u7C7B\u578B | \n
---|---|---|
immediate | \n\u662F\u5426\u8DF3\u8FC7\u52A8\u753B | \nboolean | \n
\u540D\u79F0 | \n\u8BF4\u660E | \n\u53C2\u6570 | \n
---|---|---|
default | \n\u8F6E\u64AD\u5185\u5BB9 | \n- | \n
indicator | \n\u81EA\u5B9A\u4E49\u6307\u793A\u5668 | \n{ active: number, total: number } | \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\u540D\u79F0 | \n\u9ED8\u8BA4\u503C | \n\u63CF\u8FF0 | \n
---|---|---|
--van-swipe-indicator-size | \n6px | \n- | \n
--van-swipe-indicator-margin | \nvar(--van-padding-sm) | \n- | \n
--van-swipe-indicator-active-opacity | \n1 | \n- | \n
--van-swipe-indicator-inactive-opacity | \n0.3 | \n- | \n
--van-swipe-indicator-active-background | \nvar(--van-primary-color) | \n- | \n
--van-swipe-indicator-inactive-background | \nvar(--van-border-color) | \n- | \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
\u5C06 Swipe \u7EC4\u4EF6\u7684 stop-propagation \u5C5E\u6027\u8BBE\u7F6E\u4E3A false \u5373\u53EF\u907F\u514D\u8BE5\u95EE\u9898\u3002
\n\u53C2\u89C1\u684C\u9762\u7AEF\u9002\u914D\u3002
\nVant \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
\nSwipe \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\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
<!-- 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
\nthis.$refs.swipe.resize();\n
\n