el-carousel和el-image组合实现swiper左右滑动图片,点击某张图片放大预览的效果

简介: el-carousel和el-image组合实现swiper左右滑动图片,点击某张图片放大预览的效果

image.png

<template>
    <el-carousel 
        class="image-swiper" 
        :height="'100%'" 
        :indicator-position="swiperItems.length <= 1 ? 'none' : ''"
        :arrow="swiperItems.length <= 1 ? 'never' : ''">
        <el-carousel-item v-for="(a, $i) in swiperItems" :key="$i">
            <el-image 
                style="width: 100%; height: 100%" 
                :src="a.sm" 
                :preview-src-list="swiperItems.map(v => v.lg)" 
                :initial-index="$i"
                :fit="'cover'">
            </el-image>
        </el-carousel-item>
    </el-carousel>
</template>
<script>
export default {
    data() {
        return {
            swiperItems: [
                {
                    sm: "static/img/sm/1.jpg",
                    lg: "static/img/lg/1.jpg",
                },
                {
                    sm: "static/img/sm/2.jpg",
                    lg: "static/img/lg/2.jpg",
                },
                {
                    sm: "static/img/sm/3.jpg",
                    lg: "static/img/lg/3.jpg",
                },
            ],
        };
    },
};
</script>
<style lang="scss" scoped>
.image-swiper {
    position: absolute;
    width: 400px;
    height: 300px;
    position: absolute;
    margin: auto;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}
</style>


相关文章
element中使用走马灯效果el-carousel点击按钮切换第几页demo效果示例(整理)
element中使用走马灯效果el-carousel点击按钮切换第几页demo效果示例(整理)
|
中间件 API
nuxt3:接口转发,实现跨域
nuxt3:接口转发,实现跨域
1321 0
|
前端开发 Java 关系型数据库
【Mybatis-Plus】mybatisplus更新时,实体字段为空,数据库不更新的解决方案
【Mybatis-Plus】mybatisplus更新时,实体字段为空,数据库不更新的解决方案
1146 0
|
JavaScript
【vue】vue2 获取本地IP地址
【vue】vue2 获取本地IP地址
557 1
vue3 element-ui-plus Carousel 跑马灯 的使用 及 踩坑记录
本文介绍了在Vue 3中使用Element UI Plus的Carousel组件实现跑马灯效果的方法,并分享了在实现过程中遇到的常见问题和解决方案。
vue3 element-ui-plus Carousel 跑马灯 的使用 及 踩坑记录
|
资源调度 JavaScript 前端开发
Vue2项目使用v-viewer插件实现图片预览、切换、缩放、旋转...
这篇文章介绍了在Vue 2项目中如何通过`v-viewer`插件实现图片的预览、切换、缩放、旋转等功能,并提供了插件的安装、配置和使用方法。
4351 0
Vue2项目使用v-viewer插件实现图片预览、切换、缩放、旋转...
|
存储 JavaScript 前端开发
成功解决:Cannot read properties of undefined (reading ‘commit‘)
这篇文章提供了解决Vuex中"Cannot read properties of undefined (reading 'commit')"错误的两种方法:检查模板中的数据属性是否存在,以及确保在Vue实例中正确挂载了store对象。
成功解决:Cannot read properties of undefined (reading ‘commit‘)
|
JavaScript
基于Element UI或Element Plus实现具有倒计时的Message消息提示
本文介绍了如何在Element UI或Element Plus框架中实现具有倒计时功能的消息提示组件,支持多次点击生成多个独立倒计时的消息提示,并提供了详细的实现代码和使用示例。
1190 1
基于Element UI或Element Plus实现具有倒计时的Message消息提示
|
前端开发 JavaScript 开发者
< elementUi 下拉选择框组件 树状部门选择( 多选/单选 )>
在前端开发中,为解决ElementUI缺少处理树状数据选择的Select组件问题,封装了一个Vue子组件`SelectTree`。组件支持单选和多选,具备搜索功能和懒加载特性。单选示例展示了如何展示树状部门数据,而多选则增加了已选内容的取消功能。此外,还新增了根据等级限制选择的功能。文章提供了详细的代码实现和效果截图,对需要此类组件的开发者具有参考价值。
1052 1
< elementUi 下拉选择框组件 树状部门选择( 多选/单选 )>
|
JavaScript API 数据安全/隐私保护
数美滑块验证码分析
本文以官网的滑块验证码为例,分析验证过程,完成模拟验证。
2246 0
数美滑块验证码分析