如何在vuejs 2中的现有行中附加数据

时间:2018-03-17 14:27:21

标签: javascript vuejs2

我有一个这样的数组对象:

0:{total_electricity_generated: 1567.7910000000002}
1:{total_electricity_generated: 1468.4869999999999}
2:{total_electricity_generated: 498.7319999999999}
3:{total_electricity_generated: 461.8369999999999}

有没有办法在vuejs 2中的现有行中附加数据?

0:{total_electricity_generated: 1567.7910000000002, anotherValue: 1}
1:{total_electricity_generated: 1468.4869999999999, anotherValue: 2}
2:{total_electricity_generated: 498.7319999999999, anotherValue: 3}
3:{total_electricity_generated: 461.8369999999999, anotherValue: 4}

1 个答案:

答案 0 :(得分:1)

尝试这样

const vApp = new Vue({
    el:'#app',
    data: { 
        test: [{
             entry: 'first'
          }] 
   }
})

vApp.test[0].anotherValue = 1