mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(ShareSheet): add options description (#6460)
* feat(share-sheet): share sheet add option * feat(share-sheet): add options intro * feat(ShareSheet): add options description Co-authored-by: zhanglin <zhanglin_0715@youzan.com>
This commit is contained in:
parent
472c4f35ae
commit
c445b12507
@ -87,6 +87,23 @@ export default {
|
|||||||
/>
|
/>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
showShare: false,
|
||||||
|
options: [
|
||||||
|
{ name: 'Wechat', icon: 'wechat' },
|
||||||
|
{ name: 'Weibo', icon: 'weibo' },
|
||||||
|
{ name: 'Link', icon: 'link', description: 'Description' },
|
||||||
|
{ name: 'Poster', icon: 'poster' },
|
||||||
|
{ name: 'Qrcode', icon: 'qrcode' },
|
||||||
|
],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
### Props
|
### Props
|
||||||
@ -111,6 +128,7 @@ export default {
|
|||||||
| Key | Description | Type |
|
| Key | Description | Type |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| name | Option name | _string_ |
|
| name | Option name | _string_ |
|
||||||
|
| description | Option description | _string_ |
|
||||||
| icon | Option icon,can be set to `wechat` `weibo` `qq` `link` `qrcode` `poster` or image URL | _string_ |
|
| icon | Option icon,can be set to `wechat` `weibo` `qq` `link` `qrcode` `poster` or image URL | _string_ |
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
@ -122,7 +122,7 @@ export default {
|
|||||||
|
|
||||||
### 展示描述信息
|
### 展示描述信息
|
||||||
|
|
||||||
通过`description`属性可以设置标题下方的描述文字
|
通过`description`属性可以设置标题下方的描述文字, 给`options`属性设置`description`可以添加分享选项描述
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<van-share-sheet
|
<van-share-sheet
|
||||||
@ -133,6 +133,23 @@ export default {
|
|||||||
/>
|
/>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
showShare: false,
|
||||||
|
options: [
|
||||||
|
{ name: '微信', icon: 'wechat' },
|
||||||
|
{ name: '微博', icon: 'weibo' },
|
||||||
|
{ name: '复制链接', icon: 'link', description: '描述信息' },
|
||||||
|
{ name: '分享海报', icon: 'poster' },
|
||||||
|
{ name: '二维码', icon: 'qrcode' },
|
||||||
|
],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
### Props
|
### Props
|
||||||
@ -159,6 +176,7 @@ export default {
|
|||||||
| 键名 | 说明 | 类型 |
|
| 键名 | 说明 | 类型 |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| name | 分享渠道名称 | _string_ |
|
| name | 分享渠道名称 | _string_ |
|
||||||
|
| description | 分享选项描述 | _string_ |
|
||||||
| icon | 图标,可选值为 `wechat` `weibo` `qq` `link` `qrcode` `poster`,支持传入图片 URL | _string_ |
|
| icon | 图标,可选值为 `wechat` `weibo` `qq` `link` `qrcode` `poster`,支持传入图片 URL | _string_ |
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
<van-share-sheet
|
<van-share-sheet
|
||||||
v-model="show.withDesc"
|
v-model="show.withDesc"
|
||||||
:title="t('title')"
|
:title="t('title')"
|
||||||
:options="options"
|
:options="optionsWithDesc"
|
||||||
:description="t('description')"
|
:description="t('description')"
|
||||||
@select="onSelect"
|
@select="onSelect"
|
||||||
/>
|
/>
|
||||||
@ -138,6 +138,20 @@ export default {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
optionsWithDesc() {
|
||||||
|
return [
|
||||||
|
{ name: this.t('wechat'), icon: 'wechat' },
|
||||||
|
{ name: this.t('weibo'), icon: 'weibo' },
|
||||||
|
{
|
||||||
|
name: this.t('link'),
|
||||||
|
icon: 'link',
|
||||||
|
description: this.t('description'),
|
||||||
|
},
|
||||||
|
{ name: this.t('poster'), icon: 'poster' },
|
||||||
|
{ name: this.t('qrcode'), icon: 'qrcode' },
|
||||||
|
];
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -92,6 +92,11 @@ export default createComponent({
|
|||||||
>
|
>
|
||||||
<img src={this.getIconURL(option.icon)} class={bem('icon')} />
|
<img src={this.getIconURL(option.icon)} class={bem('icon')} />
|
||||||
{option.name && <span class={bem('name')}>{option.name}</span>}
|
{option.name && <span class={bem('name')}>{option.name}</span>}
|
||||||
|
{option.description && (
|
||||||
|
<span class={bem('option-description')}>
|
||||||
|
{option.description}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
@ -65,6 +65,12 @@
|
|||||||
font-size: @share-sheet-option-name-font-size;
|
font-size: @share-sheet-option-name-font-size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__option-description {
|
||||||
|
padding: 0 @padding-base;
|
||||||
|
color: @share-sheet-option-description-color;
|
||||||
|
font-size: @share-sheet-option-description-font-size;
|
||||||
|
}
|
||||||
|
|
||||||
&__cancel {
|
&__cancel {
|
||||||
display: block;
|
display: block;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
@ -596,6 +596,8 @@
|
|||||||
@share-sheet-icon-size: 48px;
|
@share-sheet-icon-size: 48px;
|
||||||
@share-sheet-option-name-color: @gray-7;
|
@share-sheet-option-name-color: @gray-7;
|
||||||
@share-sheet-option-name-font-size: @font-size-sm;
|
@share-sheet-option-name-font-size: @font-size-sm;
|
||||||
|
@share-sheet-option-description-color: @gray-5;
|
||||||
|
@share-sheet-option-description-font-size: @font-size-sm;
|
||||||
@share-sheet-cancel-button-font-size: @font-size-lg;
|
@share-sheet-cancel-button-font-size: @font-size-lg;
|
||||||
@share-sheet-cancel-button-height: 48px;
|
@share-sheet-cancel-button-height: 48px;
|
||||||
@share-sheet-cancel-button-background: @white;
|
@share-sheet-cancel-button-background: @white;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user