Define a global variable that automatically transforms the value

I globally define a variable scrollIndex
clipboard.png
1

clipboard.png
2;

clipboard.png
3

clipboard.png
(figure 4, click trigger to slide the right interface to the corresponding area)

the theory should be: click event execution (figure 1) assign scrollIndex to 1, then execute (figure 4), when the slide ends, scrollIndex is re-assigned to-1, and then executed (figure 3). The only place where scrollIndex is assigned to-1 is the initialization assignment (figure 1) and the assignment (figure 4). But what caused the value of scrollIndex to be changed to-1. Ask the great god for advice.

Mar.09,2021

I don't understand. Didn't you assign a value of-1 when you declared?


the information you gave is not enough. It should be a logic error. There is a simple way. You intercept the modification of scrollIndex with Proxy or some other getter function, and add a judgment if (oldValue! ='- 1' & & newValue ='- 1') Then add a break point to the null operation so that once scrollIndex is changed from a value other than '- 1' to '- 1' , it will stop and then look at the call stack. Or you simply do not add breakpoints step by step violent tracking, as long as you are willing to take the time to debug it.


you can refer to other people's dynamic anchor implementation


var a = "asd";
.
Menu