swiper插件报错 vue_vue.js - vue项目中使用swiper插件出现生命周期报错!

问 题

vue-cli引入swiper插件,页面上轮播运行正常,但是一直出现这个报错!

HTML:

JS:

import vfooter from './footer/footer'

export default {

name: 'home-page',

components: {

vfooter

},

data() {

return {

banners: [

'../../static/images/carousel-pic.jpg',

'../../static/images/carousel-pic.jpg',

'../../static/images/carousel-pic.jpg'

],

items: [

"2017年全民创业-你还在等什么1?",

"2017年全民创业-你还在等什么2?",

"2017年全民创业-你还在等什么3?"

],

swiperOption: {

pagination: '.swiper-pagination',

autoplay: 3000,

slidesPerView: 'auto',

centeredSlides: true,

paginationClickable: true

// direction: 'vertical'

}

}

},

computed: {

swiper() {

return this.$refs.mySwiper.swiper;

}

},

mounted () {

this.swiper.slideTo(0,0,false)

}

}

解决方案

你的refs.mySwiper不存在啊.

扫一扫关注IT屋

微信公众号搜索 “ IT屋 ” ,选择关注与百万开发者在一起

你可能感兴趣的:(swiper插件报错,vue)