How to pass the value of props to data? in vue2

The platitudes of

have been searched for N many times and tried many methods, but they still haven"t solved
nonsense, which is mainly the value obtained dynamically by props. Change the initial value of initialSlide in swiper4
code screenshot is as follows:
this is the parent screenshot:

clipboard.png

clipboard.png

clipboard.png

clipboard.png

:

clipboard.png

clipboard.png

clipboard.png

:

clipboard.png

clipboard.png


clipboard.png

clipboard.png

is here, the value of gallaryindex is dynamic, but it cannot be transmitted to initialSlide here, that is, the picture I clicked will not show that I clicked on the
that I have been tossing about for a long time, but I still can"t solve it. I really hope that the boss can give us some advice, and it"s best to put on the code!

Mar.09,2021

you can only set the initial value when you set it in data , so if you want to change gallaryindex , you can change it watch , and then update it in watch .

subcomponents

data () {
    return {
        swiperOption: {
            ...,
            initialSlide: this.gallaryindex,
            ...
        }
    }
},

watch: {
    gallaryindex (val) {
        this.swiperOption.initialSlide = val
    }
}
Menu