vue-swipe轮播图

一、安装饿了么团队开发的vue专用的轮播图插件:vue-swipe
npm install vue-swipe

二、在index.js文件中引用vue-swipe

require('vue-swipe/dist/vue-swipe.css');
import { Swipe, SwipeItem } from 'vue-swipe';

三、在index.js中注册组件

Vue.component('swipe', Swipe);
Vue.component('swipe-item', SwipeItem);

四、在需要使用的components下面的.vue页面中直接引用

  <swipe class="my-swipe">
      <swipe-item class="slide1">1</swipe-item>
      <swipe-item class="slide2">2</swipe-item>
      <swipe-item class="slide3">3</swipe-item>
   </swipe>

需要写样式。样式例子:

.my-swipe {
  height: 200px;
  color: #fff;
  font-size: 30px;
  text-align: center;
}

.slide1 {
  background-color: #0089dc;
  color: #fff;
}

.slide2 {
  background-color: #ffd705;
  color: #000;
}

.slide3 {
  background-color: #ff2d4b;
  color: #fff;
}

vue-swipe的github地址:
https://github.com/ElemeFE/vue-swipe

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容