七、Vue组件库:Element、Swiper(轮播专用组件) (3)

【0】-【3】

<template> <div> <h1>路由实例parent</h1> <hr/> <!-- 【1】使用swiper的轮播组件 --> <swiper :options="swiperOption" ref="mySwiper" @someSwiperEvent="callback"> <!-- slides --> <swiper-slide v-for="(img,i) in imgs" :key="i"> <img :src="img"/> </swiper-slide> <!-- Optional controls --> <div slot="pagination"></div><!--分页器。如果放置在swiper-container外面,需要自定义样式。--> <!-- <div slot="button-prev"></div> <div slot="button-next"></div> <div slot="scrollbar"></div> --> </swiper> </div> </template> <script> export default{ name:\'parent\', components:{}, data(){ return{ //【2】配置轮播相关参数都写在此对象内部 swiperOption: { pagination: { el: \'.swiper-pagination\', }, }, imgs:[//【0】定义一些图片 "https://hbimg.huabanimg.com/a84ec58661bc95efb974e2eebea2b3fd880a8fb12870a-ksYmbV_fw658", "https://cli.clewm.net/file/2015/01/20/81b71bc509d09368d4602a4b5b05d093.jpg", "https://hbimg.huabanimg.com/a84ec58661bc95efb974e2eebea2b3fd880a8fb12870a-ksYmbV_fw658", ] } }, filters:{}, directives:{}, } </script> <style scoped> /* 【3】控制轮播图样式 */ .swiper-container{ --swiper-theme-color: #ff6600; --swiper-pagination-color: #00ff33;/* 两种都可以 */ } img { width:800px; } </style>

效果:

在这里插入图片描述

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zgzwgg.html