logo
  • 教程列表
  • SO官方文檔
  • 陣列變化檢測警告
    • 對於巢狀陣列
    • 包含陣列的物件陣列
    • 使用 Vue.set
    • 使用 Array.prototype.splice
  1. StackOverflow 文件
  2. Vue.js 教程
  3. 陣列變化檢測警告
  4. 包含陣列的物件陣列

包含陣列的物件陣列

Created: November-22, 2018

new Vue({
    el: '#app',
    data:{
        myArr : [
            {
                name: 'object-1',
                nestedArr: ['apple', 'banana']
            },
            {
                name: 'object-2',
                nestedArr: ['grapes', 'orange']
            }
        ]
    },
    methods:{
        changeArrayItem: function(){
            this.$set(this.myArr[1].nestedArr, 1, 'strawberry');
        }
    }
}) 

這是小提琴的連結

  • 使用 Vue.set
  • 對於巢狀陣列

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明