question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot read property 'swiper' of undefined" when 'not-next-tick:true' in mounted

See original GitHub issue

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 image image

I need swiper instance first time,but I can’t get it Someone else know why and how?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
mangoqilicommented, Sep 8, 2017

The reason for the real mistake is that this swiper’s parent has v-if, change v-if to v-show

0reactions
honey93commented, Jun 27, 2018

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Swiper: Uncaught (in promise) TypeError: Cannot read ...
I am validating first if there are any images available on my images property or not, if there is an image then render...
Read more >
Getting Started With Swiper
Installation. There are few options on how to include/import Swiper into your project: Install from NPM. We can install Swiper from NPM $...
Read more >
nolimits4web/Swiper - Gitter
Uncaught TypeError : Cannot read property 'offsetWidth' of undefined .scrollbar.set @ swiper.js:2555 .onResize @ swiper.js:999.
Read more >
Changing slides using buttons above swiper - Ionic Forum
Since Swiper is not initialized before the button, ... Uncaught TypeError: Cannot read properties of null (reading 'slideNext'). Thanks!
Read more >
how to get current slide element index in swiper js react
When using event listeners on swiper instance error TypeError: Cannot read properties of undefined (reading 'event_name') occur where event_name is the name ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found