Element UI picture walking lamp application

Keep a moon o 2021-09-15 09:48:29

install element ui

One 、 stay Vue Install dependencies in project , Enter installation instructions at the terminal :npm i element-ui -S

Two 、 Import dependence , stay main.js introduce :

image.png

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);
 Copy code 

newly build Carousel.vue Components

image.png


<template>
<el-carousel indicator-position="none" loop="true" interval="2000" trigger="click"> <el-carousel-item v-for="item in images" :key="item"> <img :src="item.url" alt=" No pictures "/> </el-carousel-item> </el-carousel>
</template>
<script> export default { name: "Carousel", data() { return { images: [ { url: require("@/assets/1.jpg")}, { url: require("@/assets/2.jpg")}, { url: require("@/assets/3.jpg")}, { url: require("@/assets/4.jpg")}, { url: require("@/assets/5.jpg")}, { url: require("@/assets/logo.png")} ], }; }, }; </script>
<style scoped> .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>
 Copy code 

Import components

<template>
<el-main style="border: #42B983 1px solid">
<Carousel></Carousel>
</el-main>
</template>
<script>
import Carousel from './utils/Carousel'
export default {
components: {
Carousel
}
}
</script>
 Copy code 

Results display : image.png

Please bring the original link to reprint ,thank
Similar articles

2021-09-15

2021-09-15