javascript - 使用 Vue 时从烧瓶 api 迭代和显示结果的问题
问题描述
我第一次学习 Flask/Vue 教程(在https://testdriven.io/blog/developing-a-single-page-app-with-flask-and-vuejs/找到)我正在尝试使其适应我的需要。为了保存列出完整代码,我似乎遇到问题的部分在这里:
<table class="table table-hover">
<thead>
<tr>
<th scope="col">Note</th>
<th scope="col">User</th>
<th></th>
</tr>
</thead>
<tbody>
<tr v-for="(note, index) in notes" :key="index">
<td>{{ note.note }}</td>
<td>{{ note.index }}</td>
<td>
<div class="btn-group" role="group">
<button
type="button"
class="btn btn-warning btn-sm"
v-b-modal.note-update-modal
@click="editNote(note)">
Update
</button>
<button
type="button"
class="btn btn-danger btn-sm"
@click="onDeleteNote(note)">
Delete
</button>
</div>
</td>
</tr>
</tbody>
</table>
并且更新 html 表的函数created()
是:
methods: {
getNotes() {
const path = 'http://localhost:5000/api/v1/resources/notes/';
axios.get(path)
.then((res) => {
this.notes = res.data.notes;
})
.catch((error) => {
// eslint-disable-next-line
console.error(error);
});
},
...
出于某种原因,在教程版本中,HTML 表完美地更新了数据库元素,但是当我尝试更改字段名称后它不会,而且我无法发现我的错误。
我尝试使用 console.log(res) 代替函数并记录数据,但似乎提供的函数无法使用我的字段名称工作。
任何人都可以让初学者摆脱痛苦吗?
提前致谢
解决方案
推荐阅读
- flutter - FileSystemException:无法复制文件'(操作系统错误:是目录,errno = 21)
- javascript - 使用 fs.readFileSync 读取 private.key,前缀操作中的无效左侧表达式
- django - 从 django 模板页面浏览文件
- google-slides-api - google slide api用python在两点之间绘制直线
- python - scylla 4.4是否支持python3.9?
- java - 基于类别名称显示项目的 Firestore 集合组查询
- mysql - SQL - 选择具有两个不同条件的两列
- c++ - Visual Studio C++:同一程序在不同的可执行文件名下使用不同数量的 RAM
- python - Python3 - 在内部循环中更新“power”变量会修改外部循环的聚合变量
- sql - 如何在 Hive SQL 中编写嵌套映射结构