搭建CLI步奏过程不详细介绍了
主要利用Vue.component()注册全局组件,滑动效果使用了translateX
如下图

让后开始详细介绍如何实现自己的轮播组件
一.新建jv-swiper文件夹
1.1、然后在jv-swiper文件夹新建index.vue ,该vue其实为swiper的外层控制
<template>
<div class="jv-swiper" ref="swileng">
<slot></slot>
<div v-if="indicator==='true'" class="indicator-box">//此段代码为指示器,轮播的小点点
<div v-for="(i,index) in jv_siwdom" :key="index" :class="jv_siw_index==index?'indicator_color':''" class="indicator"> </div>
</div>
</div>
</template>
<script>
/* eslint-disable */
export default {
name: "JvSwiper",
porps: {},
data() {
return {
indicator: true,
jv_siwdom: 0,
jv_siw_index: 0,
};
},
created() {},
mounted() {
let jv_interval = 3000,//滑动间隔
jv_duration = 300,//运动时间
jv_indicator = tru

本文通过Vue CLI3.0创建了一个自定义轮播组件,利用Vue.component注册全局组件,采用translateX实现滑动效果。详细步骤包括新建组件文件、注册组件、在main.js中引入以及组件使用方法。同时,讨论了如何获取用户设置的参数和轮播数量,寻求优化建议。
最低0.47元/天 解锁文章
2910

被折叠的 条评论
为什么被折叠?



