简体   繁体   English

Vue Js列表渲染变化数组带拼接

[英]Vue Js List Rendering Change Array With Splice

    let vm = new Vue({
        el:"#app",
        data:{
            users:[
                {
                    name:"Murad"
                },
                {
                    name:"Maxi"
                },

            ]
        }
    })

vm.users[1] = {name:"John"}; vm.users[1] = {name:"John"};

this is not work but这是行不通的,但是

vm.users.splice(0,1,{name:"John"}) vm.users.splice(0,1,{name:"John"})

and after vm.users[1] = {name:"John"};在 vm.users[1] = {name:"John"};

this is work Why after splice change array with index work?这是工作为什么在拼接更改数组后使用索引工作?

Vue doesn't trigger a change for a modified array value, but does for splice Vue 不会触发修改后的数组值的更改,但会触发拼接

https://v2.vuejs.org/v2/guide/list.html#Mutation-Methods https://v2.vuejs.org/v2/guide/list.html#Mutation-Methods

Vue will automatically trigger for the following array functions: Vue 会自动触发以下数组函数:

  • push()推()
  • pop()流行音乐()
  • shift()转移()
  • unshift()取消移位()
  • splice()拼接()
  • sort()种类()
  • reverse()撤销()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM