Vue does a function of moving up and down, but the effect doesn't work.

the interface is as follows:

clipboard.png

:"" ""

"" :


clipboard.png

finally, I printed out the data, and the location did change, but the interface didn"t change. Why?

Dec.23,2021

vue's bi-directional data binding mechanism makes it impossible to manipulate arrays directly with subscripts
refer to ide/list.html?-sharp%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9" rel=" nofollow noreferrer "> https://cn.vuejs.org/v2/guide.

for details.

in order to solve the first type of problem, the following two ways can achieve the same effect as vm.items [indexOfItem] = newValue, and will also trigger a status update:

// Vue.set
Vue.set(vm.items, indexOfItem, newValue)
// Array.prototype.splice
vm.items.splice(indexOfItem, 1, newValue)

you can also use the vm.$set instance method, which is an alias for the global method Vue.set:

vm.$set(vm.items, indexOfItem, newValue)


= assigning and modifying length is not supported
just use set

Menu