Swiper initializes the first time to get the element undefined

it makes sense to initialize the callback init to indicate that swiper should be loaded, but what you get is undefined , and it"s normal to add a timer. What"s the problem?

html

<div class="swiper-container">
    <div class="swiper-wrapper">
        <div class="swiper-slide">Slide 1</div>
        <div class="swiper-slide">Slide 2</div>
        <div class="swiper-slide">Slide 3</div>
    </div>

    <!--  -->
    <div class="swiper-button-prev"></div>
    <div class="swiper-button-next"></div>

</div>

JavaScript

window.onload = () => {
    new Swiper(".swiper-container", {
        // loop: true,
        // 
        navigation: {
            nextEl: ".swiper-button-next",
            prevEl: ".swiper-button-prev",
        },
        on: {
            init() {
                console.log("")
                console.log(this.navigation.nextEl) //undefined

                setTimeout(() => {
                    console.log(this.navigation.nextEl); //object
                }, 10)
            }
        }
    })
}

clipboard.png

undefined

init demo

clipboard.png

Jun.25,2021

Hello friend, it is officially recommended to call mySwiper.navigation.$prevEl

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b372c1-2c079.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b372c1-2c079.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?