Vue. js moves the array position and updates the view method. The vue. js Array
Use vue. js v-for to bind several options. You need to sort and move the options up and down.
The position of the array in options needs to be exchanged, which is usually written as follows:
Suppose to move one forward:
Var index = this. options. indexOf (option); // obtain the index of the current option object in the array. Var tempOption = this. options [index-1]; // store the previous one. options [index-1] = option; (this. options [index]) this. options [index] = tempOption;
In this way, the order of the array is indeed changed, but the view is not updated and moved. For details, see the vue official website array description.
One solution is to change the object and use the vue's set method:
Var index = options. indexOf (option); var tempOption = options [index-1]; Vue. set (options, index-1, options [index]); Vue. set (options, index, tempOption );
The above vue. js moves the array location, and the method for updating the view is all the content that I have shared with you. I hope to give you a reference, and I hope you can provide more support for the customer's house.