vue封裝swiper

參考:https://github.com/surmon-china/vue-awesome-swipercss

npm install vue-awesome-swiper --save

全局引入vue

import Vue from 'vue'
import VueAwesomeSwiper from 'vue-awesome-swiper'

// require styles
import 'swiper/dist/css/swiper.css'

Vue.use(VueAwesomeSwiper, /* { default global options } */)

局部:git

// require styles
import 'swiper/dist/css/swiper.css'

import { swiper, swiperSlide } from 'vue-awesome-swiper'

export default {
  components: {
    swiper,
    swiperSlide
  }
}

要usegithub

import Swiper from 'swiper'
Swiper.use({
  name: 'pluginName',
  params: {
    pluginSwitch: false,
  },
  on: {
    init() {
      if (!this.params.pluginSwitch) return
      console.log('init')
    },
    // swiper callback...
  }
})

防止初始化過早。要搞key,vue的key不同dom就會刪除從新渲染npm

未完。。。dom

相關文章
相關標籤/搜索