カルーセルスライダーを実装できる「vue-easy-slider」

by kabanoki

HTML

<div id="app">
  <slider animation="fade">
    <slider-item
      v-for="(i, index) in list"
      :key="index"
      :style="i"
    >
      <p style="line-height: 280px; font-size: 5rem; text-align: center;">Page{{ index + 1 }}</p>
    </slider-item>
  </slider>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue-easy-slider.umd.js"></script>

CSS

body {
  background: #20262E;
  padding: 20px;
  font-family: Helvetica;
}

#app {
  background: #fff;
  border-radius: 4px;
  padding: 20px;
  transition: all 0.2s;
}

Vue

const { Slider, SliderItem } = window['vue-easy-slider'];

let app = new Vue({
  el: '#app',
  components: {
    Slider,
    SliderItem,
  },
  data: {
    list: [
      { backgroundColor: '#3f51b5', width: '100%', height: '100%' },
      { backgroundColor: '#eee', width: '100%', height: '100%' },
      { backgroundColor: '#f44336', width: '100%', height: '100%' },
    ],
  }
});