vue3+swiper11 横向的循环切换图片
vue
vuejs/vue: 是一个用于构建用户界面的 JavaScript 框架,具有简洁的语法和丰富的组件库,可以用于开发单页面应用程序和多页面应用程序。
项目地址:https://gitcode.com/gh_mirrors/vu/vue
免费下载资源
·
利用Swiper制作横向循环图片
<template>
<div class="summaryE">
<div class="E_two">
<swiper
:slidesPerView="5"
loop
:autoplay="{ delay: 5000, disableOnInteraction: true }"
:navigation="true"
:pagination="{ clickable: true }"
:scrollbar="{ draggable: true }"
:space-between="0"
:modules="modules"
effect="coverflow"
:coverflowEffect="{
rotate: 0, //slide做3d旋转时Y轴的旋转角度
stretch: 1, //每个slide之间的拉伸值,越大slide靠得越紧。5.3.6 后可使用%百分比
depth: 80, //slide的位置深度。值越大z轴距离越远,看起来越小。
modifier: 7, //depth和rotate和stretch的倍率,相当于depth*modifier、rotate*modifier、stretch*modifier,值越大这三个参数的效果越明显
slideShadows: false //是否开启slide阴影
}"
@mouseenter="enter"
@mouseleave="leave"
@swiper="onSwiper"
@slideChange="onSlideChange">
<swiper-slide v-for="(item, index) in arrList" :key="index" class="swiperItem">
<!-- <img :src="item.img" alt="" /> -->
<img :src="item.img" class="hzhb"/>
</swiper-slide>
</swiper>
</div>
</div>
</template>
<script setup>
import { useRouter } from 'vue-router'
import { ref,defineProps, toRaw ,onMounted} from "vue";
const router = useRouter()
onMounted(() => {
});
import { Swiper, SwiperSlide } from "swiper/vue";
import "swiper/css";
import "swiper/css/navigation";
import "swiper/css/pagination";
import 'swiper/css/effect-coverflow'; //effect为fade时必须引入,否则可能出现只切换一次就不自动切换的情况
import { Autoplay, Navigation, Pagination, Scrollbar, A11y ,EffectCoverflow} from "swiper/modules";
let modules = [Autoplay, Navigation, Pagination, Scrollbar, A11y,EffectCoverflow];
//定义swiperNew,目的获取非响应式swiper
let swiperNew = null;
//鼠标移入
const enter = () => {
swiperNew.autoplay.stop();
};
//鼠标移出
const leave = () => {
swiperNew.autoplay.start();
};
const onSwiper = (swiper) => {
// console.log(swiper);
swiperNew = toRaw(swiper); //拿到swiper对象再转换为非响应式
};
const rightClick=()=>{
swiperNew.slidePrev()
}
const leftClick=()=>{
swiperNew.slideNext()
}
const onSlideChange = () => {
// console.log("slide change");
};
const arrList = ref([
{
img:require('@/assets/computer/rongyu/r1.png'),
},{
img:require('@/assets/computer/rongyu/r1.png'),
},{
img:require('@/assets/computer/rongyu/r1.png'),
},{
img:require('@/assets/computer/rongyu/r1.png'),
},{
img:require('@/assets/computer/rongyu/r1.png'),
},{
img:require('@/assets/computer/rongyu/r1.png'),
},
])
</script>
<style scoped>
.E_two{
width: 100%;
}
.hzhb{
width: 100%;
height: auto;
}
</style>
效果
GitHub 加速计划 / vu / vue
80
16
下载
vuejs/vue: 是一个用于构建用户界面的 JavaScript 框架,具有简洁的语法和丰富的组件库,可以用于开发单页面应用程序和多页面应用程序。
最近提交(Master分支:4 个月前 )
73486cb5
* chore: fix link broken
Signed-off-by: snoppy <michaleli@foxmail.com>
* Update packages/template-compiler/README.md [skip ci]
---------
Signed-off-by: snoppy <michaleli@foxmail.com>
Co-authored-by: Eduardo San Martin Morote <posva@users.noreply.github.com> 6 个月前
e428d891
Updated Browser Compatibility reference. The previous currently returns HTTP 404. 6 个月前
更多推荐
已为社区贡献12条内容
所有评论(0)