SPA mode get swiper instance undefined
See original GitHub issueVue.js version 2.3.4, component version 2.6.7, swiper 3.2.4
I can’t get swiper instance by computed
example code below
<template>
<swiper class="honor-carousel" :options="config" ref="honorSwiper">
<swiperSlide
v-for="(item, idx) in honorList"
:key="idx">
<div class="honor-item">
<div class="img">
<img :src="item.img" alt="">
</div>
<div class="text">{{ item.title }}</div>
</div>
</swiperSlide>
</swiper>
</template>
<script>
import { swiper, swiperSlide } from 'vue-awesome-swiper'
import { honorList } from './data'
export default {
name: 'honor',
components: {
swiper,
swiperSlide
},
data() {
return {
config: {
pagination: '.swiper-pagination',
spaceBetween: 14,
slidesPerView: 1,
loop: true,
loopAdditionalSlides: 10,
initialSlide: 1,
paginationClickable: true,
grabCursor: true,
onSlideChangeEnd: this.check
},
honorList
}
},
computed: {
__swiper__() {
return this.$refs.honorSwiper.swiper
}
},
methods: {
check() {
console.log(this.__swiper__)
}
},
mounted() {
console.log(this.__swiper__)
}
}
</script>
there is no async process in this example. the check methods and mounted methods output undefined both, what should i do to get the swiper instance? hope to get your reply, thx.
Issue Analytics
- State:
- Created 6 years ago
- Comments:15 (4 by maintainers)
Top Results From Across the Web
Can't access swiper js instance of a glider - WordPress.org
swiperInstance = imageCarousel.data( 'swiper' );. I would need to make it work also for the glider. for some reason I get undefined for...
Read more >ScrollTrigger seem to fail randomly + other issues - GreenSock
Cannot read properties of undefined. I'm getting an error when loading a page when you don't start at the "top" of the page,...
Read more >Why is my swiper undefined? - Stack Overflow
This is because of scoping issue. inside the click handler, the scope is changed and it does not have access to innerSwiper.
Read more >The $q object - Quasar Framework
Reference to Capacitor global object. Available only when running under a Capacitor app. Usage. The following sections will teach you how to use...
Read more >Jmol/JSmol Interactive Script Documentation
in order to switch into "math mode" temporarily to obtain a variable, ... Use of undefined variables in Jmol is not an error;...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The right approach is add this.$nextTick in the callback.
so, to return the swiper is not a good idea?