问题
vue2和swiper低版本兼容性不好,在以 siwper@5.4.5 写一个平滑滚动(类似京东首页的'发现好货')页时,发现
①平滑滚动linear css修改不生效
②.autoplay.stop() 无法立即停止,需要下一个<swiper-slide></swiper-slide>就位后才停止
解决:
① /css中修改linear不生效,则在mounted中直接更改
this.$refs.mySwiper.$swiper.$wrapperEl[0].style["transition-timing-function"] = "linear";
②swiper-wrapper上的transform属性规定了这次切换后轮播图会到的位置,把这个属性的值直接改为当前轮播图的位置
import { Swiper, SwiperSlide } from "vue-awesome-swiper";
export default {
name: "swiper-example-scrollbar",
title: "Scrollbar",
components: {
Swiper,
SwiperSlide,
},
data() {
return {
nextTransForm: "",
nextTime: 0,
swiperOption: {
loop: true, //是否循环
speed: 4000,
slidesPerView: 4,
autoplay: {
delay: 0,
stopOnLastSlide: