vue.js - 如何从vue axios响应中检索表的数字列名的值
问题描述
所以我的表结构如下
编号 | 姓名 | 1 | 2 | 3 | 4 | created_at | 更新时间
我想从 vue axios 调用的响应对象中获取第 1、2、3、4 列的值。
axios.get('/someAPIpage/').then(response => {
this.name = response.data[0].name;
this.a1 = response.data[0].1;
this.a2 = response.data[0].2;
this.a3 = response.data[0].3;
this.a4 = response.data[0].4;
});
但我没有成功,这可能是因为我的列名是数字。那么我怎样才能得到这些数字列值呢?任何帮助表示赞赏。
解决方案
使用括号表示法:
axios.get('/someAPIpage/').then(response => {
this.name = response.data[0].name;
this.a1 = response.data[0]['1'];
this.a2 = response.data[0]['2'];
this.a3 = response.data[0]['3'];
this.a4 = response.data[0]['4'];
});
推荐阅读
- c++ - c ++ typedef修复模板参数
- r - R DiagrammeR 包 - 动态更新图表
- sql-server - 如何在 MS SQL 中检查文本或 excel 文件是否已打开或被某些用户使用
- angular - 如何在 Angular Material 中使用 mat-slide-toggle 的 MatSlideToggleChange
- javascript - 在网格中上下移动形状
- haskell - 折叠不在范围内
- forms - 使用 Odoo 中 res.users 的外键获取用户详细信息
- javascript - javascript 正则表达式不是在中间包含单词
- iot - 如何在 Node-red 中模拟数千台设备
- counter - 禁用看门狗时的替代方案