解决mint-ui的swipe组件在使用中遇到的一个问题,进入首页后,滑动栏从第一页直接滑动到第二个页面,在第一页没有停留。
由于录制gif的原因,这里把2当作1,3当作2,一打开页面是,直接从页面2跳到页面3,页面2的停留时间极短。
而我们期望的结果是一进入页面时页面是从页面1停留后跳到页面2,再到页面3,这样有序的循环播放,向下面的gif才是正常的。
解决方案:
:class="{'is-active': !index}"
完整代码:
<template>
<mt-swipe class="swipe" :auto="10000">
<mt-swipe-item v-for="(item, index) in list" :key="index" :class="{'is-active': !index}">
<header class="swipe-title">{{item.title}}</header>
<div class="swipe-content">{{item.content}}</div>
<footer class="swipe-footer"><router-link class="swipe-action" :to="{name: item.router}"></router-link></footer>
</mt-swipe-item>
</mt-swipe>
</template>
这样就能解决一进入网页滑动栏就从页面1跳到页面2的问题。