<template>
    <div class="swiper">
        <el-carousel :interval="5000" arrow="always" height="214px" indicator-class="custom-indicator">
            <el-carousel-item v-for="item in swiperData" :key="item">
                <img :src="item.imgurl" :alt="item.title">
                <span>
                    <NuxtLink :to="{path:`/newsDetail/${item.id}`,query:{listId:routeId,listName:routeName}}" target="_blank" :title="item.title">{{item.title}}</NuxtLink>
                </span>
            </el-carousel-item>
        </el-carousel>
    </div>
</template>

<script setup>
import { ElCarousel, ElCarouselItem } from 'element-plus'
const props = defineProps({
    swiperData: Array
});

</script>

<style lang="less" scoped>
.swiper {
    width: 380px;
    height: 214px;
    position: relative;

    img {
        width: 380px;
        height: 214px;
    }

    span {
        display: inline-block;
        width: 370px;
        height: 30px;
        line-height: 30px;
        padding-left: 13px;
        position: absolute;
        top: 0;
        left: 0;
        font-family: PingFang SC, PingFang SC;
        font-weight: 500;
        font-size: 20px;
        color: #FFFFFF;
        background-color: rgba(0, 0, 0, 0.5);
        white-space: nowrap;      /* 禁止换行 */
        overflow: hidden;        /* 隐藏超出部分 */
        text-overflow: ellipsis; /* 超出部分显示省略号 */
        a{
            color: #fff;
        }
    }
}

.el-carousel {
    /deep/.el-carousel__arrow i {
        font-size: 30px !important;
    }

    /deep/.el-carousel__arrow--left {
        left: 16px;
        width: 35px;
        height: 57px;
        color: #616358;
        background: #dcdedc;
        position: absolute;
        left: 0px;
        border: none;
        border-radius: 0;
    }

    /deep/.el-carousel__arrow--right {
        right: 16px;
        width: 35px;
        height: 57px;
        color: #616358;
        background: #dcdedc;
        position: absolute;
        right: 0;
        border: none;
        border-radius: 0;
    }

    /deep/ .el-carousel__indicators {
        // 指示器
        left: unset;
        transform: unset;
        right: 41%;
    }

    /deep/ .el-carousel__button {
        // 指示器按钮
        width: 10px;
        height: 10px;
        border: none;
        border-radius: 50%;
        border: 1px solid #fff;
        background-color: transparent;
    }

    /deep/ .is-active .el-carousel__button {
        // 指示器激活按钮
        background: #fff;
    }

    /deep/ .el-carousel__container {
        height: 100%;
    }
}

.custom-indicator button {
    background-color: #fff;
    border: 1px solid #ccc;
    opacity: 0.7;
}

.custom-indicator button.is-active {
    background-color: #333;
    border-color: #333;
    opacity: 1;
}
</style>