template:
<swiper :options="swiperOption" :not-next-tick="notNextTick" ref="mySwiper">
<slide v-for="item in XXX">
</swiper
script:
data:{
notNextTick: true,
swiperOption: {
initialSlide: 0,
onlyExternal: true,
onInit: (swiper) => {
console.log(swiper)
},
onReachEnd: (swiper) => {
console.log('last slide')
}
}
},
computed: {
swiper () {
return this.$refs.mySwiper.swiper
}},
mounted () {
console.log(this)
console.log(this.swiper)
}
all above is my real code refered to README/#Use in SPA
error in broswer and never console


I need swiper instance first time,but I can't get it
Someone else know why and how?
Format and refine your code.
I'm sorry, I did not get this error here, is it caused by other code?
@surmon-china Thank you,I also dont't know why it is. I can console the 'this' and find the swiper in 'this'. The close next console can't log the swiper. Key code as above. I am not sure the error caused by other.I will check my code more carefully to find the original error
The reason for the real mistake is that this context is incorrect, this is undefined, so no swiper object.
The reason for the real mistake is that this swiper's parent has v-if, change v-if to v-show
I am also facing the same issue, on initial load it is showing the swiperobject but once I route and come back to that same page, I do face that issue.
Most helpful comment
The reason for the real mistake is that this swiper's parent has v-if, change v-if to v-show