SlideTo problem of vue using swiper

the first page is 1 2 3 4 4 lists
the second page is swiper page, which corresponds to four
pages in the first page. After clicking 3 on the first page, the index value is brought to the second page
, and then after the second page is received, it jumps to the corresponding swiper page with slideTo

.

looks like it should be fine
, but it just doesn"t succeed

this is a vue project. The data of the entire page is obtained by axios from the background

.

new Swiper and slideTo are both written in mounted

I tried to write new Swiper and slideTo where axios was successful in getting data, but it didn"t work either

use the initialSlide parameter, but not

hit a breakpoint. It seems that no matter what, when slideTo is executed, the page has not been rendered yet, but the data is already available

.

just write new swiper and slideTo to the updated hook


data does not mean that dom has been rendered. You can try to get the data and put it in this.$nextTick to new Swiper, or you can new Swiper, and other nextTick and then call the update method of swiper

.
Menu