feat: migrate ShareSheet component

This commit is contained in:
chenjiahan 2020-07-25 22:04:21 +08:00
parent 70f6146981
commit bb445b74ef
7 changed files with 35 additions and 25 deletions

View File

@ -6,6 +6,8 @@
- Circle: `v-model` 重命名为 `v-model:currentRate` - Circle: `v-model` 重命名为 `v-model:currentRate`
- Popup: `v-model` 重命名为 `v-model:show` - Popup: `v-model` 重命名为 `v-model:show`
- ShareSheet: `v-model` 重命名为 `v-model:show`
- ActionSheet: `v-model` 重命名为 `v-model:show`
- Switch: v-model 对应的属性 `value` 重命名为 `modelValue`,事件由 `input` 重命名为 `update:modelValue` - Switch: v-model 对应的属性 `value` 重命名为 `modelValue`,事件由 `input` 重命名为 `update:modelValue`
- Sidebar: v-model 对应的属性 `activeKey` 重命名为 `modelValue`,事件由 `input` 重命名为 `update:modelValue` - Sidebar: v-model 对应的属性 `activeKey` 重命名为 `modelValue`,事件由 `input` 重命名为 `update:modelValue`
- TreeSelect: `active-id.sync` 重命名为 `v-model:active-id` - TreeSelect: `active-id.sync` 重命名为 `v-model:active-id`

View File

@ -32,4 +32,5 @@ module.exports = [
'sidebar', 'sidebar',
'tree-select', 'tree-select',
'notice-bar', 'notice-bar',
'share-sheet',
]; ];

View File

@ -16,7 +16,7 @@ Vue.use(ShareSheet);
```html ```html
<van-cell title="Show ShareSheet" @click="showShare = true" /> <van-cell title="Show ShareSheet" @click="showShare = true" />
<van-share-sheet <van-share-sheet
v-model="showShare" v-model:show="showShare"
title="Share" title="Share"
:options="options" :options="options"
@select="onSelect" @select="onSelect"
@ -51,7 +51,7 @@ export default {
### Multi Line ### Multi Line
```html ```html
<van-share-sheet v-model="showShare" title="Share" :options="options" /> <van-share-sheet v-model:show="showShare" title="Share" :options="options" />
``` ```
```js ```js
@ -80,7 +80,7 @@ export default {
```html ```html
<van-share-sheet <van-share-sheet
v-model="showShare" v-model:show="showShare"
:options="options" :options="options"
title="Share" title="Share"
description="Description" description="Description"

View File

@ -22,7 +22,7 @@ Vue.use(ShareSheet);
```html ```html
<van-cell title="显示分享面板" @click="showShare = true" /> <van-cell title="显示分享面板" @click="showShare = true" />
<van-share-sheet <van-share-sheet
v-model="showShare" v-model:show="showShare"
title="立即分享给好友" title="立即分享给好友"
:options="options" :options="options"
@select="onSelect" @select="onSelect"
@ -60,7 +60,7 @@ export default {
```html ```html
<van-share-sheet <van-share-sheet
v-model="showShare" v-model:show="showShare"
title="立即分享给好友" title="立即分享给好友"
:options="options" :options="options"
/> />
@ -93,7 +93,7 @@ export default {
除了使用内置的几种图标外,可以直接在 `icon` 中传入图片 URL 来使用自定义的图标。 除了使用内置的几种图标外,可以直接在 `icon` 中传入图片 URL 来使用自定义的图标。
```html ```html
<van-share-sheet v-model="showShare" :options="options" /> <van-share-sheet v-model:show="showShare" :options="options" />
``` ```
```js ```js
@ -126,7 +126,7 @@ export default {
```html ```html
<van-share-sheet <van-share-sheet
v-model="showShare" v-model:show="showShare"
:options="options" :options="options"
title="立即分享给好友" title="立即分享给好友"
description="描述信息" description="描述信息"

View File

@ -3,7 +3,7 @@
<demo-block card :title="t('basicUsage')"> <demo-block card :title="t('basicUsage')">
<van-cell is-link :title="t('showSheet')" @click="show.basic = true" /> <van-cell is-link :title="t('showSheet')" @click="show.basic = true" />
<van-share-sheet <van-share-sheet
v-model="show.basic" v-model:show="show.basic"
:title="t('title')" :title="t('title')"
:options="options" :options="options"
@select="onSelect" @select="onSelect"
@ -17,7 +17,7 @@
@click="show.multiLine = true" @click="show.multiLine = true"
/> />
<van-share-sheet <van-share-sheet
v-model="show.multiLine" v-model:show="show.multiLine"
:title="t('title')" :title="t('title')"
:options="multiLineOptions" :options="multiLineOptions"
@select="onSelect" @select="onSelect"
@ -31,7 +31,7 @@
@click="show.customIcon = true" @click="show.customIcon = true"
/> />
<van-share-sheet <van-share-sheet
v-model="show.customIcon" v-model:show="show.customIcon"
:options="customIconOptions" :options="customIconOptions"
@select="onSelect" @select="onSelect"
/> />
@ -40,7 +40,7 @@
<demo-block card :title="t('withDesc')"> <demo-block card :title="t('withDesc')">
<van-cell is-link :title="t('showSheet')" @click="show.withDesc = true" /> <van-cell is-link :title="t('showSheet')" @click="show.withDesc = true" />
<van-share-sheet <van-share-sheet
v-model="show.withDesc" v-model:show="show.withDesc"
:title="t('title')" :title="t('title')"
:options="optionsWithDesc" :options="optionsWithDesc"
:description="t('description')" :description="t('description')"

View File

@ -15,6 +15,7 @@ export default createComponent({
props: { props: {
...popupMixinProps, ...popupMixinProps,
title: String, title: String,
duration: [Number, String],
cancelText: String, cancelText: String,
description: String, description: String,
getContainer: [String, Function], getContainer: [String, Function],
@ -40,6 +41,8 @@ export default createComponent({
}, },
}, },
emits: ['cancel', 'select', 'update:show', 'click-overlay'],
methods: { methods: {
onCancel() { onCancel() {
this.toggle(false); this.toggle(false);
@ -51,7 +54,7 @@ export default createComponent({
}, },
toggle(val) { toggle(val) {
this.$emit('input', val); this.$emit('update:show', val);
}, },
getIconURL(icon) { getIconURL(icon) {
@ -63,8 +66,10 @@ export default createComponent({
}, },
genHeader() { genHeader() {
const title = this.slots('title') || this.title; const title = this.$slots.title ? this.$slots.title() : this.title;
const description = this.slots('description') || this.description; const description = this.$slots.description
? this.$slots.description()
: this.description;
if (!title && !description) { if (!title && !description) {
return; return;
@ -132,8 +137,8 @@ export default createComponent({
return ( return (
<Popup <Popup
round round
show={this.show}
class={bem()} class={bem()}
value={this.value}
position="bottom" position="bottom"
overlay={this.overlay} overlay={this.overlay}
duration={this.duration} duration={this.duration}
@ -143,8 +148,10 @@ export default createComponent({
closeOnPopstate={this.closeOnPopstate} closeOnPopstate={this.closeOnPopstate}
closeOnClickOverlay={this.closeOnClickOverlay} closeOnClickOverlay={this.closeOnClickOverlay}
safeAreaInsetBottom={this.safeAreaInsetBottom} safeAreaInsetBottom={this.safeAreaInsetBottom}
onInput={this.toggle} {...{
onClick-overlay={this.onClickOverlay} 'onUpdate:show': this.toggle,
'onClick-overlay': this.onClickOverlay,
}}
> >
{this.genHeader()} {this.genHeader()}
{this.genRows()} {this.genRows()}

View File

@ -208,10 +208,10 @@ module.exports = {
// path: 'pull-refresh', // path: 'pull-refresh',
// title: 'PullRefresh 下拉刷新', // title: 'PullRefresh 下拉刷新',
// }, // },
// { {
// path: 'share-sheet', path: 'share-sheet',
// title: 'ShareSheet 分享面板', title: 'ShareSheet 分享面板',
// }, },
{ {
path: 'swipe-cell', path: 'swipe-cell',
title: 'SwipeCell 滑动单元格', title: 'SwipeCell 滑动单元格',
@ -542,10 +542,10 @@ module.exports = {
// path: 'pull-refresh', // path: 'pull-refresh',
// title: 'PullRefresh', // title: 'PullRefresh',
// }, // },
// { {
// path: 'share-sheet', path: 'share-sheet',
// title: 'ShareSheet', title: 'ShareSheet',
// }, },
{ {
path: 'swipe-cell', path: 'swipe-cell',
title: 'SwipeCell', title: 'SwipeCell',