feat: migrate Swipe component

This commit is contained in:
chenjiahan 2020-08-17 10:12:56 +08:00
parent 79511fe331
commit f978642277
5 changed files with 20 additions and 15 deletions

View File

@ -62,4 +62,6 @@ module.exports = [
'notify', 'notify',
'collapse', 'collapse',
'collapse-item', 'collapse-item',
'swipe',
'swipe-item',
]; ];

View File

@ -56,8 +56,8 @@ export default createComponent({
render() { render() {
return ( return (
<div class={bem()} style={this.style} {...{ on: this.$listeners }}> <div class={bem()} style={this.style}>
{this.shouldRender && this.slots()} {this.shouldRender ? this.$slots.default?.() : null}
</div> </div>
); );
}, },

View File

@ -12,7 +12,9 @@
<demo-block :title="t('title2')"> <demo-block :title="t('title2')">
<van-swipe :autoplay="3000"> <van-swipe :autoplay="3000">
<van-swipe-item v-for="(image, index) in images" :key="index"> <van-swipe-item v-for="(image, index) in images" :key="index">
<img v-lazy="image" /> <img :src="image" />
<!-- TODO -->
<!-- <img v-lazy="image" /> -->
</van-swipe-item> </van-swipe-item>
</van-swipe> </van-swipe>
</demo-block> </demo-block>

View File

@ -62,6 +62,8 @@ export default createComponent({
}, },
}, },
emits: ['change'],
data() { data() {
return { return {
rect: null, rect: null,
@ -385,10 +387,9 @@ export default createComponent({
genIndicator() { genIndicator() {
const { count, activeIndicator } = this; const { count, activeIndicator } = this;
const slot = this.slots('indicator');
if (slot) { if (this.$slots.indicator) {
return slot; return this.$slots.indicator();
} }
if (this.showIndicators && count > 1) { if (this.showIndicators && count > 1) {
@ -414,7 +415,7 @@ export default createComponent({
style={this.trackStyle} style={this.trackStyle}
class={bem('track', { vertical: this.vertical })} class={bem('track', { vertical: this.vertical })}
> >
{this.slots()} {this.$slots.default?.()}
</div> </div>
{this.genIndicator()} {this.genIndicator()}
</div> </div>

View File

@ -273,10 +273,10 @@ module.exports = {
path: 'sticky', path: 'sticky',
title: 'Sticky 粘性布局', title: 'Sticky 粘性布局',
}, },
// { {
// path: 'swipe', path: 'swipe',
// title: 'Swipe 轮播', title: 'Swipe 轮播',
// }, },
{ {
path: 'tag', path: 'tag',
title: 'Tag 标记', title: 'Tag 标记',
@ -607,10 +607,10 @@ module.exports = {
path: 'sticky', path: 'sticky',
title: 'Sticky', title: 'Sticky',
}, },
// { {
// path: 'swipe', path: 'swipe',
// title: 'Swipe', title: 'Swipe',
// }, },
{ {
path: 'tag', path: 'tag',
title: 'Tag', title: 'Tag',