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

ShareSheet

\n

Intro

\n

A pop-up sharing panel at the bottom for displaying the action buttons corresponding to each sharing channel, without specific sharing logic.

\n

Install

\n

Register component globally via app.use, refer to Component Registration for more registration ways.

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

Usage

\n

Basic Usage

\n
<van-cell title="Show ShareSheet" @click="showShare = true" />\n<van-share-sheet\n  v-model:show="showShare"\n  title="Share"\n  :options="options"\n  @select="onSelect"\n/>\n
\n
import { ref } from 'vue';\nimport { showToast } from 'vant';\n\nexport default {\n  setup() {\n    const showShare = ref(false);\n    const options = [\n      { name: 'WeChat', icon: 'wechat' },\n      { name: 'Weibo', icon: 'weibo' },\n      { name: 'Link', icon: 'link' },\n      { name: 'Poster', icon: 'poster' },\n      { name: 'Qrcode', icon: 'qrcode' },\n    ];\n\n    const onSelect = (option) => {\n      showToast(option.name);\n      showShare.value = false;\n    };\n\n    return {\n      options,\n      onSelect,\n      showShare,\n    };\n  },\n};\n
\n

Multi Line

\n
<van-share-sheet v-model:show="showShare" title="Share" :options="options" />\n
\n
import { ref } from 'vue';\n\nexport default {\n  setup() {\n    const showShare = ref(false);\n    const options = [\n      [\n        { name: 'WeChat', icon: 'wechat' },\n        { name: 'WeChat Moments', icon: 'wechat-moments' },\n        { name: 'Weibo', icon: 'weibo' },\n        { name: 'QQ', icon: 'qq' },\n      ],\n      [\n        { name: 'Link', icon: 'link' },\n        { name: 'Poster', icon: 'poster' },\n        { name: 'Qrcode', icon: 'qrcode' },\n        { name: 'Weapp Qrcode', icon: 'weapp-qrcode' },\n      ],\n    ];\n\n    return {\n      options,\n      showShare,\n    };\n  },\n};\n
\n

Custom Icon

\n
<van-share-sheet v-model:show="showShare" :options="options" />\n
\n
import { ref } from 'vue';\n\nexport default {\n  setup() {\n    const showShare = ref(false);\n    const options = [\n      {\n        name: 'Name',\n        icon: 'https://fastly.jsdelivr.net/npm/@vant/assets/custom-icon-fire.png',\n      },\n      {\n        name: 'Name',\n        icon: 'https://fastly.jsdelivr.net/npm/@vant/assets/custom-icon-light.png',\n      },\n      {\n        name: 'Name',\n        icon: 'https://fastly.jsdelivr.net/npm/@vant/assets/custom-icon-water.png',\n      },\n    ];\n\n    return {\n      options,\n      showShare,\n    };\n  },\n};\n
\n

Show Description

\n
<van-share-sheet\n  v-model:show="showShare"\n  :options="options"\n  title="Share"\n  description="Description"\n/>\n
\n
import { ref } from 'vue';\n\nexport default {\n  setup() {\n    const showShare = ref(false);\n    const options = [\n      { name: 'WeChat', icon: 'wechat' },\n      { name: 'Weibo', icon: 'weibo' },\n      { name: 'Link', icon: 'link', description: 'Description' },\n      { name: 'Poster', icon: 'poster' },\n      { name: 'Qrcode', icon: 'qrcode' },\n    ];\n\n    return {\n      options,\n      showShare,\n    };\n  },\n};\n
\n

API

\n

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\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
AttributeDescriptionTypeDefault
v-model:showWhether to show ShareSheetbooleanfalse
optionsShare optionsOption[][]
titleTitlestring-
cancel-textCancel button textstring\'Cancel\'
descriptionDescriptionstring-
durationTransition duration, unit secondnumber | string0.3
z-indexSet the z-index to a fixed valuenumber | string2000+
roundWhether to show round cornerbooleantrue
overlayWhether to show overlaybooleantrue
overlay-classCustom overlay classstring | Array | object-
overlay-styleCustom overlay styleobject-
lock-scrollWhether to lock background scrollbooleantrue
lazy-renderWhether to lazy render util appearedbooleantrue
close-on-popstateWhether to close when popstatebooleantrue
close-on-click-overlayWhether to close when overlay is clickedbooleantrue
safe-area-inset-bottomWhether to enable bottom safe area adaptationbooleantrue
teleportSpecifies a target element where ShareSheet will be mountedstring | Element-
before-closeCallback function before close(action: string) => boolean | Promise<boolean>-
\n

Data Structure of Option

\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
KeyDescriptionType
nameOption namestring
descriptionOption descriptionstring
iconOption icon, can be set to wechat weibo qq link qrcode poster weapp-qrcode wechat-moments or image URLstring
classNameOption className is used to set the class props to the share itemstring
\n

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\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
EventDescriptionArguments
selectEmitted when an option is clickedoption: Option, index: number
cancelEmitted when the cancel button is clicked-
openEmitted when opening ShareSheet-
closeEmitted when closing ShareSheet-
openedEmitted when ShareSheet is opened-
closedEmitted when ShareSheet is closed-
click-overlayEmitted when overlay is clickedevent: MouseEvent
\n

Slots

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
NameDescription
titleCustom title
descriptionCustom description
cancelCustom the content of cancel button
\n

Types

\n

The component exports the following type definitions:

\n
import type {\n  ShareSheetProps,\n  ShareSheetOption,\n  ShareSheetOptions,\n} from 'vant';\n
\n

Theming

\n

CSS Variables

\n

The component provides the following CSS variables, which can be used to customize styles. Please refer to ConfigProvider component.

\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\n\n
NameDefault ValueDescription
--van-share-sheet-header-paddingvar(--van-padding-sm) var(--van-padding-md) var(--van-padding-base)-
--van-share-sheet-title-colorvar(--van-text-color)-
--van-share-sheet-title-font-sizevar(--van-font-size-md)-
--van-share-sheet-title-line-heightvar(--van-line-height-md)-
--van-share-sheet-description-colorvar(--van-text-color-2)-
--van-share-sheet-description-font-sizevar(--van-font-size-sm)-
--van-share-sheet-description-line-height16px-
--van-share-sheet-icon-size48px-
--van-share-sheet-option-name-colorvar(--van-gray-7)-
--van-share-sheet-option-name-font-sizevar(--van-font-size-sm)-
--van-share-sheet-option-description-colorvar(--van-text-color-3)-
--van-share-sheet-option-description-font-sizevar(--van-font-size-sm)-
--van-share-sheet-cancel-button-font-sizevar(--van-font-size-lg)-
--van-share-sheet-cancel-button-height48px-
--van-share-sheet-cancel-button-backgroundvar(--van-background-2)-
\n
'},null,8,e))}}}]);