Element Carousel 走馬燈的具體實現(xiàn)
本文來源于Element官方文檔:
http://element-cn.eleme.io/#/zh-CN/component/carousel
基礎用法
普通走馬燈
<div class="block"> <span class="demonstration">默認 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>
組件— 走馬燈
基礎用法
<template> <div class="block"> <span class="demonstration">默認 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">默認 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">默認 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ù) | 說明 | 類型 | 可選值 | 默認值 |
---|---|---|---|---|
height | 走馬燈的高度 | string | — | — |
initial-index | 初始狀態(tài)激活的幻燈片的索引,從 0 開始 | number | — | 0 |
trigger | 指示器的觸發(fā)方式 | string | click | — |
autoplay | 是否自動切換 | boolean | — | true |
interval | 自動切換的時間間隔,單位為毫秒 | number | — | 3000 |
indicator-position | 指示器的位置 | string | outside/none | — |
arrow | 切換箭頭的顯示時機 | string | always/hover/never | hover |
type | 走馬燈的類型 | string | card | — |
Carousel Events
事件名稱 | 說明 | 回調(diào)參數(shù) |
---|---|---|
change | 幻燈片切換時觸發(fā) | 目前激活的幻燈片的索引,原幻燈片的索引 |
Carousel Methods
方法名 | 說明 | 參數(shù) |
---|---|---|
setActiveItem | 手動切換幻燈片 | 需要切換的幻燈片的索引,從 0 開始;或相應 el-carousel-item 的 name 屬性值 |
prev | 切換至上一張幻燈片 | — |
next | 切換至下一張幻燈片 | — |
Carousel-Item Attributes
參數(shù) | 說明 | 類型 | 可選值 | 默認值 |
---|---|---|---|---|
name | 幻燈片的名字,可用作 setActiveItem 的參數(shù) | string | — | — |
label | 該幻燈片所對應指示器的文本 | string | — | — |
到此這篇關(guān)于Element Carousel 走馬燈的具體實現(xiàn)的文章就介紹到這了,更多相關(guān)Element Carousel 走馬燈內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
vue3中使用router路由實現(xiàn)跳轉(zhuǎn)傳參的方法
這篇文章主要介紹了vue3中使用router路由實現(xiàn)跳轉(zhuǎn)傳參的方法,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2023-03-03解決router.beforeEach()動態(tài)加載路由出現(xiàn)死循環(huán)問題
這篇文章主要介紹了解決router.beforeEach()動態(tài)加載路由出現(xiàn)死循環(huán)問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-10-10VSCode前端Vue項目引入Element-ui組件三步簡單操作方法
elementui相當于一個庫,封裝好的內(nèi)容,我們引入到vue項目中,就可用庫中的內(nèi)容,這篇文章主要給大家介紹了關(guān)于VSCode前端Vue項目引入Element-ui組件的三步簡單操作方法,需要的朋友可以參考下2024-07-07基于Element封裝一個表格組件tableList的使用方法
這篇文章主要介紹了基于Element封裝一個表格組件tableList的使用方法,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2020-06-06