javascript - 如何在vuejs 2中的现有行中追加数据

标签 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}

最佳答案

试试这样

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

vApp.test[0].anotherValue = 1

关于javascript - 如何在vuejs 2中的现有行中追加数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49337987/

相关文章:

javascript - Isotope Jquery 插件布局问题

javascript - 在 vuejs 中联合两个或多个对象

javascript - 让Vue注册datepicker事件

javascript - 如何从webpack javascript中的文件夹,子文件夹及其子文件夹动态获取文件

vue.js - Vue 和 Vuex v-for 状态改变时不能正常更新

javascript - ReactJS中ClassicComponentClass和ComponentClass的区别

javascript - location.href 和 window.location.href 之间的性能差异

javascript - Flot Javascript - 绘制 24 小时条形图,其中包含每小时的值

javascript - 我想在我的 <ul> 菜单中添加一些动态菜单功能。

javascript - Vue JS Vuetify $emit 第一次没有工作