2022.10.13

大家好,今天我使用了vue+element实现走马灯的效果,类似于轮播图,可以进行一个图片的滑动。

Hello, everyone. Today, I used vue+element to realize the effect of rotating lights, which is similar to the wheel cast diagram, and can slide an image.

接下来就让我向大家展示如何使用它,并且解决其中遇到的问题。

Let me show you how to use it and solve the problems you encounter.

首先是element官方文档里面的写法。
The first is the way it's written in element's official documentation.

(Element - The world's most popular Vue UI framework)

<!-- carousel走马灯 --><el-carousel:interval="3000"type="card"height="300px"><el-carousel-item v-for="item in 4" :key="item"><h3 class="medium">{{ item }}</h3></el-carousel-item></el-carousel>
/* 走马灯样式 */
.el-carousel__item h3 {color: #475669;font-size: 14px;opacity: 0.75;line-height: 200px;margin: 0;
}.el-carousel__item:nth-child(2n) {background-color: #99a9bf;
}.el-carousel__item:nth-child(2n + 1) {background-color: #d3dce6;
}

这是最初始的写法,实现的效果如图:

This is the initial way of writing, and the effect is shown below:

看上去是不是和swipter轮播图差不多,所以当时我就想直接把跑马灯变成轮播图实现。

It looks similar to swipter, so at that time I wanted to directly turn the running light into a wheel.

我的做法是这样的:

<el-carousel-item v-for="item in list" :key="item">

把4换成list,存放数组,然后就要新建一个数组。

I'm going to replace 4 with list, store the array, and then I'm going to create a new array.

data(){return{list:[{img:require('../assets/img/a.jpg')},{img:require('../assets/img/b.jpg')},{img:require('../assets/img/c.jpg')}]}}

当时我把data后面的括号变成:以及return后面多加了:然后就导致我的list数组没有被定义。

I changed the parentheses after data to: and the parentheses after return to:, which resulted in my list being undefined.

接着就要用差值表达式渲染数据。

Then you render the data with a difference expression.

 <el-carousel-item v-for="item in list" :key="item"><img :src="item.img" ></el-carousel-item>

src和:src的区别,src是当成字符串解析,:src是当成变量解析。

The difference between src, which is parsed as a string, and :src, which is parsed as a variable.

效果如图所示:

The effect is shown as follows:

这样就实现了一个swipter轮播图。

In this way, a swipter rotcast graph is implemented.

大家喜欢的话点个赞,支持一下!

If you like it, click a like and support it!

vue+element之carousel走马灯的使用(The use of vue+element carousel)相关推荐

  1. (Carousel)解决:Element-ui 中 Carousel 走马灯的样式的修改问题

    Ⅰ.Element-ui 提供的组件与想要目标情况的对比: 1.Element-ui 提供组件情况: 其一.Element-ui 自提供的代码情况为(示例的代码,例子如下): // Element-u ...

  2. element走马灯自动_Element Carousel 走马灯的具体实现

    本文来源于Element官方文档: 基础用法 普通走马灯 默认 Hover 指示器触发 {{ item }} Click 指示器触发 {{ item }} 组件- 走马灯 基础用法 默认 Hover ...

  3. element 往node里面增加属性值_【Vue原理】Compile - 源码版 之 Parse 属性解析

    写文章不容易,点个赞呗兄弟 专注 Vue 源码分享,文章分为白话版和 源码版,白话版助于理解工作原理,源码版助于了解内部详情,让我们一起学习吧 研究基于 Vue版本 [2.5.17] 如果你觉得排版难 ...

  4. vue + element ui 的后台管理系统框架_从零开始搭建 VUE + Element UI后台管理系统框架...

    点击右上方红色按钮关注"web秀",让你真正秀起来 前言 后台管理系统前端框架,现在很流行的形式都是,上方和左侧都是导航菜单,中间是具体的内容.比如阿里云.七牛云.头条号.百家号等 ...

  5. 使用 iview 实现PC端生成推广海报与二维码并下载的功能,基于iview Modal 对话框 与 Carousel 走马灯组件实现

    使用 iview 实现PC端生成推广海报与二维码并下载的功能,基于iview Modal 对话框 与 Carousel 走马灯组件实现 前言:最近在对公司网页进行改版的时候遇到一个问题,需要在PC端实 ...

  6. Vue.js 3.0企业级管理后台开发实战:基于Element Plus UI

    Vue.js 3.0企业级管理后台开发实战:基于Element Plus UI - 每天更新 前言 文章内容 项目源码及课件 第1章 项目启动 1.1 项目原型 1.2 项目UI 1.3 项目开发流程 ...

  7. vue方法调用失败后多次调用_浅析Vue中 computed / watch / methods的区别

    思考:请说下Vue中computed 和 watch 的区别( 面试题 ) 构造选项 computed / watch / methods computed ● computed 起初构想 在Vue的 ...

  8. vue v-if判断数组元素的值_我对Vue项目上线做的一些基本优化

    前言 大家好啊,我是wangly19,一名前端摸鱼小能手.最近忙着开源项目的东西,还有公司项目的迭代问题,导致更新文章的频率有点低了.也来聊聊我在干嘛吧. 第一个事情就是比较我的阉割版UI Desig ...

  9. vue入门到启动_一篇超完整的Vue新手入门指导教程

    前言 新建项目近些年前端开发快速发展,现在学习前端已经不像以前那样仅仅学习一个语法就可以了,它已经是一门编程技术了,它们有自己独立的类似Main函数的入口,有像MVC一样规范好的层次结构,有自己的开发 ...

最新文章

  1. 如何选择正确的激活函数?
  2. 分布式电子邮件系统设计--转载
  3. C#判断字符串是否为数字字符串
  4. Linux下C语言程序的内存布局
  5. Docker部署SpringBoot的两种方法,后一种一键部署超好用!
  6. python怎么输入一个数字并调用_python如何直接输入上一句话,如何快速打出上一句话...
  7. 如何去掉Orcad Capture中元件标号下划线
  8. java arraylist add时默认调用tostring_java中如何调用toString命名的方法?
  9. vue-cli 体验
  10. RSTP比STP快在哪?
  11. 项目总结:初稿与定稿,方向相差180度
  12. windows系统安装下GCC编译器
  13. Visual Studio Installer 无法下载安装,长时间停留在下载界面。vs_community__1502218517.1623916988.exe
  14. 磁共振线圈分类_MRI技师必须知道的磁共振软硬件知识
  15. 原来JSON还可这样玩着
  16. Springboot与手机的互动
  17. 多点触摸TP的touch异常事件
  18. 基于MATLAB GUI的魔方三维动态还原仿真程序
  19. r语言for循环怎么写
  20. 北京财经频道专访|美信CEO 胡建强:让IT和工业物联网没有难采的数据

热门文章

  1. 迈向智能化运维的第二步:自动化运维
  2. 解放双手,推荐一款 GitHub 星标 8.2k+的命令行软件管理器
  3. 【ES6】最简单的对象数组去重的方法
  4. 硅谷外卖学习日记之babelrc
  5. 【Pytorch基础教程31】YoutubeDNN模型解析
  6. IDEA 打开项目后就闪退问题
  7. 无码间串扰与采样定理的差异
  8. 微信退款出现No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
  9. Python搭建个人博客(pelican)-快速实践~
  10. 从数据到智慧,TOOM舆情监测系统让你的决策更加精准!