Element Carousel 走馬燈的具體實(shí)現(xiàn)
本文來源于Element官方文檔:
http://element-cn.eleme.io/#/zh-CN/component/carousel
基礎(chǔ)用法
普通走馬燈
<div class="block"> <span class="demonstration">默認(rèn) Hover 指示器觸發(fā)</span> <el-carousel height="150px"> <el-carousel-item v-for="item in 4" :key="item"> <h3>{{ item }}</h3> </el-carousel-item> </el-carousel> </div> <div class="block"> <span class="demonstration">Click 指示器觸發(fā)</span> <el-carousel trigger="click" height="150px"> <el-carousel-item v-for="item in 4" :key="item"> <h3>{{ item }}</h3> </el-carousel-item> </el-carousel> </div>
組件— 走馬燈
基礎(chǔ)用法
<template> <div class="block"> <span class="demonstration">默認(rèn) Hover 指示器觸發(fā)</span> <el-carousel height="150px"> <el-carousel-item v-for="item in 4" :key="item"> <h3 class="small">{{ item }}</h3> </el-carousel-item> </el-carousel> </div> <div class="block"> <span class="demonstration">Click 指示器觸發(fā)</span> <el-carousel trigger="click" height="150px"> <el-carousel-item v-for="item in 4" :key="item"> <h3 class="small">{{ item }}</h3> </el-carousel-item> </el-carousel> </div> </template> <style> .el-carousel__item h3 { color: #475669; font-size: 14px; opacity: 0.75; line-height: 150px; margin: 0; } .el-carousel__item:nth-child(2n) { background-color: #99a9bf; } .el-carousel__item:nth-child(2n+1) { background-color: #d3dce6; } </style>
指示器
<template> <div class="block"> <span class="demonstration">默認(rèn) Hover 指示器觸發(fā)</span> <el-carousel height="150px"> <el-carousel-item v-for="item in 4" :key="item"> <h3 class="small">{{ item }}</h3> </el-carousel-item> </el-carousel> </div> <div class="block"> <span class="demonstration">Click 指示器觸發(fā)</span> <el-carousel trigger="click" height="150px"> <el-carousel-item v-for="item in 4" :key="item"> <h3 class="small">{{ item }}</h3> </el-carousel-item> </el-carousel> </div> </template> <style> .el-carousel__item h3 { color: #475669; font-size: 14px; opacity: 0.75; line-height: 150px; margin: 0; } .el-carousel__item:nth-child(2n) { background-color: #99a9bf; } .el-carousel__item:nth-child(2n+1) { background-color: #d3dce6; } </style>
切換箭頭
<template> <div class="block"> <span class="demonstration">默認(rèn) Hover 指示器觸發(fā)</span> <el-carousel height="150px"> <el-carousel-item v-for="item in 4" :key="item"> <h3 class="small">{{ item }}</h3> </el-carousel-item> </el-carousel> </div> <div class="block"> <span class="demonstration">Click 指示器觸發(fā)</span> <el-carousel trigger="click" height="150px"> <el-carousel-item v-for="item in 4" :key="item"> <h3 class="small">{{ item }}</h3> </el-carousel-item> </el-carousel> </div> </template> <style> .el-carousel__item h3 { color: #475669; font-size: 14px; opacity: 0.75; line-height: 150px; margin: 0; } .el-carousel__item:nth-child(2n) { background-color: #99a9bf; } .el-carousel__item:nth-child(2n+1) { background-color: #d3dce6; } </style>
卡片化
<template> <el-carousel :interval="4000" type="card" height="200px"> <el-carousel-item v-for="item in 6" :key="item"> <h3 class="medium">{{ item }}</h3> </el-carousel-item> </el-carousel> </template> <style> .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; } </style>
方向
<template> <el-carousel height="200px" direction="vertical" :autoplay="false"> <el-carousel-item v-for="item in 3" :key="item"> <h3 class="medium">{{ item }}</h3> </el-carousel-item> </el-carousel> </template> <style> .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; } </style>
Carousel Attributes
參數(shù) | 說明 | 類型 | 可選值 | 默認(rèn)值 |
---|---|---|---|---|
height | 走馬燈的高度 | string | — | — |
initial-index | 初始狀態(tài)激活的幻燈片的索引,從 0 開始 | number | — | 0 |
trigger | 指示器的觸發(fā)方式 | string | click | — |
autoplay | 是否自動(dòng)切換 | boolean | — | true |
interval | 自動(dòng)切換的時(shí)間間隔,單位為毫秒 | number | — | 3000 |
indicator-position | 指示器的位置 | string | outside/none | — |
arrow | 切換箭頭的顯示時(shí)機(jī) | string | always/hover/never | hover |
type | 走馬燈的類型 | string | card | — |
Carousel Events
事件名稱 | 說明 | 回調(diào)參數(shù) |
---|---|---|
change | 幻燈片切換時(shí)觸發(fā) | 目前激活的幻燈片的索引,原幻燈片的索引 |
Carousel Methods
方法名 | 說明 | 參數(shù) |
---|---|---|
setActiveItem | 手動(dòng)切換幻燈片 | 需要切換的幻燈片的索引,從 0 開始;或相應(yīng) el-carousel-item 的 name 屬性值 |
prev | 切換至上一張幻燈片 | — |
next | 切換至下一張幻燈片 | — |
Carousel-Item Attributes
參數(shù) | 說明 | 類型 | 可選值 | 默認(rèn)值 |
---|---|---|---|---|
name | 幻燈片的名字,可用作 setActiveItem 的參數(shù) | string | — | — |
label | 該幻燈片所對(duì)應(yīng)指示器的文本 | string | — | — |
到此這篇關(guān)于Element Carousel 走馬燈的具體實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)Element Carousel 走馬燈內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
如何使用yarn創(chuàng)建vite項(xiàng)目+vue3
這篇文章主要介紹了如何使用yarn創(chuàng)建vite項(xiàng)目+vue3,詳細(xì)介紹了使用vite創(chuàng)建vue3過程,本文給大家介紹的非常詳細(xì),感興趣的朋友跟隨小編一起看看吧2024-03-03如何利用 vue實(shí)現(xiàn)鼠標(biāo)懸停時(shí)顯示元素或文本
Vue.js 是一種流行的 JavaScript 框架,可以使 Web 應(yīng)用程序的開發(fā)變得更加輕松和高效,這篇文章主要介紹了在 vue 中鼠標(biāo)懸停時(shí)顯示元素或文本,需要的朋友可以參考下2023-05-05vue3中使用router路由實(shí)現(xiàn)跳轉(zhuǎn)傳參的方法
這篇文章主要介紹了vue3中使用router路由實(shí)現(xiàn)跳轉(zhuǎn)傳參的方法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-03-03解決router.beforeEach()動(dòng)態(tài)加載路由出現(xiàn)死循環(huán)問題
這篇文章主要介紹了解決router.beforeEach()動(dòng)態(tài)加載路由出現(xiàn)死循環(huán)問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-10-10Vue.js動(dòng)態(tài)添加、刪除選題的實(shí)例代碼
這篇文章主要介紹了Vue.js動(dòng)態(tài)添加、刪除選題的實(shí)例代碼,非常不錯(cuò)具有參考借鑒價(jià)值,需要的朋友可以參考下2016-09-09VSCode前端Vue項(xiàng)目引入Element-ui組件三步簡單操作方法
elementui相當(dāng)于一個(gè)庫,封裝好的內(nèi)容,我們引入到vue項(xiàng)目中,就可用庫中的內(nèi)容,這篇文章主要給大家介紹了關(guān)于VSCode前端Vue項(xiàng)目引入Element-ui組件的三步簡單操作方法,需要的朋友可以參考下2024-07-07基于Element封裝一個(gè)表格組件tableList的使用方法
這篇文章主要介紹了基于Element封裝一個(gè)表格組件tableList的使用方法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-06-06