vue+elementui Carousel 走马灯 一次轮播4张图片

vue

    <el-carousel :loop="false" :autoplay="false" height="380px">
            <el-carousel-item class="el-car-item" v-for="(list, index) in dataList" :key="index">
                <div class="title_img" v-for="(imgList,index2) in list" :key="index2">
                    <a class="card-items" :href="imgList.url" target="_blank">
                        <div class="img-zoom">
                            <img :src="imgList.image"class="" alt="">
                        </div>
                    </a>
                    <div class="item-info text-left title_urk">
                        <a class="card-items" :href="imgList.url" target="_blank">
                            <div class="item-title">{{imgList.title}}</div>
                        </a>
                        <div class="tit_pimg">
                               <!-- 市场价 -->
                                 <div class="shic_price">¥{{imgList.marketprice}}</div>
                                            <!-- 现价 -->
                                 <div class="xian_price">¥{{imgList.price}}</div>
                        </div>
                    </div>
                </div>
            </el-carousel-item>
        </el-carousel>

后端返回数据

dataList: [
        {
          "imglist": "xxx",
          "title": "xxx",
          "marketprice": "xxx",
           "price":"xxx"
        },
        {
          "imglist": "xxx",
          "title": "xxx",
          "marketprice": "xxx",
           "price":"xxx"
        },
        {
          "imglist": "xxx",
          "title": "xxx",
          "marketprice": "xxx",
           "price":"xxx"
        },
        {
         "imglist": "xxx",
          "title": "xxx",
          "marketprice": "xxx",
           "price":"xxx"
        },
        {
          "imglist": "xxx",
          "title": "xxx",
          "marketprice": "xxx",
           "price":"xxx"
        },
        {
          "imglist": "xxx",
          "title": "xxx",
          "marketprice": "xxx",
           "price":"xxx"
        },
      ]

后端返回数据处理

  findlist(){
                let obj = {
                    page: this.queryinfo.page,
					limit: this.queryinfo.size,
                }
                axios.post("{:url('/addons/shop/goods/guess_like', [], false, true)}",obj).then((res) => {
                    if (res.status == 200) {
                        this.dataList = res.data.data.data
                        console.log( this.dataList,'11111111=')
                            this.total = res.data.data.total
                        let newDataList = []
                        let current = 0
                        if(this.dataList && this.dataList.length>0){
                        for(let i=0;i<=this.dataList.length-1;i++){
                            if(i%4 !== 0 || i === 0 ){
                            if(!newDataList[current]){
                                newDataList.push([this.dataList[i]])
                            }else{
                                newDataList[current].push(this.dataList[i])
                            }
                            }else{
                            current++
                            newDataList.push([this.dataList[i]])
                            }
                        }
                        }
                        this.dataList = [...newDataList]
                                        
                      
                    }
                }).catch((err) => {
                })
    

           },

css

.el-car-item {
    width: 100%;
    display: flex;

  }
.title_img{
    width: 270px;
    height: 330px;
    border: solid #ebe9e6 1px;
    margin-right: 20px;
    cursor: pointer;
  }
  .title_img:hover{
    border: solid #ff9039 1px;
    cursor: pointer;
  }
  .img-zoom{
    width: 270px;
    height: 220px;
  }
  .img-zoom img{
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
  .title_urk{
    margin-top: 20px;
  }
.item-title{
    height: 30px;
    font-size: 14px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #333333;
    line-height: 20px;
    margin-left: 10px;
  }
 .tit_pimg{
    display: flex;
    margin-left: 10px;    
    margin-top: 20px;                     

        }
.shic_price{
    font-size: 18px;
    font-weight: 600;
    margin-top: 5px;
    color: red;

}
.xian_price{
    margin-left: 10px;
    text-decoration: line-through;
    color: #5c5252;
    margin-top: 7px;
}

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: ElementUI Carousel走马灯)是一种常用的轮播组件,可以在网页中展示多张图片或内容,支持自动播放、手动切换、循环播放等功能。它是基于Vue.js框架开发的,使用简单方便,可以快速实现网页轮播效果。 ### 回答2: elementui是一种基于Vue.js的组件库,提供了许多实用的组件,其中包括走马灯carousel走马灯是一种常见的网页交互组件,可以展示多张图片或者内容,通过自动播放或者手动切换的方式,让用户能够方便地浏览多张图片或者内容。 elementui走马灯carousel组件功能非常强大,可以满足不同场景下的需求。首先,可以通过设置autoplay属性来实现自动轮播功能,可以控制轮播间间隔和是否开启循环播放。其次,可以通过设置indicator-position属性来控制指示器的位置,可以将指示器放在左边、右边、上方、下方或者不显示。此外,elementui走马灯还支持手动切换功能,可以通过设置arrow属性来控制左右箭头是否显示。 针对不同的需求,elementui走马灯还提供了多种展示效果。比如,默认展示效果为普通模式,可以通过设置type属性为card来使图片和文字居中展示,而且还可以设置card-style属性来自定义卡片的样式。同elementui走马灯还支持分页显示,可以通过设置pager属性来显示分页器。 最后,elementui走马灯还提供了许多其他的属性和事件,可以通过这些属性和事件来实现更复杂的交互。总的来说,elementui走马灯carousel组件是一款非常实用的组件,可以简单快速地实现网页中的轮播展示功能。 ### 回答3: ElementUI是一种基于Vue.js的开源UI框架,提供了多种组件,使web应用程序的开发变得更加轻松快捷。其中,carousel 走马灯ElementUI中的一个组件,用于实现轮播图的效果。 使用ElementUIcarousel组件,只需在Vue.js项目中引入ElementUI并使用它的carousel组件即可。在使用carousel组件,需要先在html模板中定义一个元素(div),用于包含轮播图的内容。然后,在Vue.js的script标签中设置轮播图的选项(options),包括轮播图的图片以及切换间隔等。 一个ElementUI carousel的例子如下: ``` <template> <div id="carousel-example"> <el-carousel :interval="3000"> <el-carousel-item v-for="(item, index) in items" :key="index"> <img :src="item.src" class="carousel-image"> </el-carousel-item> </el-carousel> </div> </template> <script> export default { data() { return { items: [ { src: "https://picsum.photos/800/300?image=0" }, { src: "https://picsum.photos/800/300?image=1" }, { src: "https://picsum.photos/800/300?image=2" }, { src: "https://picsum.photos/800/300?image=3" }, ], }; }, }; </script> <style> .carousel-image { width: 100%; } </style> ``` 在这个例子中,我们先给轮播图的容器定义了一个id为“carousel-example”的div标签。然后,在Vue.js的script标签中,我们使用了carousel组件,并设置了切换间隔为3000毫秒。 carousel内部使用了el-carousel-items子组件,我们使用v-for循环绑定了轮播图的图片地址。图片的宽度被设置为100%。当过渡效果执行ElementUI会自动加上渐变动画以及衔接效果。 可以看到,使用ElementUIcarousel组件非常方便,只需要几行代码就可以实现轮播图的效果。这使得开发人员可以将更多的间和精力放在项目的其他方面,提高了开发效率。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值