完成主页
<template> <div class="home"> <el-button type="primary" @click="$router.push('/noteAdd')" >新增信息</el-button > <el-table :data="items" style="width: 100%"> <el-table-column prop="money" label="账目"> </el-table-column> <el-table-column prop="msg" label="备注"> </el-table-column> <el-table-column prop="date" label="日期"> </el-table-column> <el-table-column label="操作"> <template slot-scope="scope"> <div> <el-button type="text" @click="$router.push(`/noteUpdate?id=${scope.row.id}`)" >编辑</el-button > <el-button type="text" @click="delById(scope.row.id)" >删除</el-button > </div> </template> </el-table-column> </el-table> </div> </template> <script> import axios from "axios"; export default { name: "HomeView", data() { return { items: [], }; }, methods: { async getData() { var res = await axios.get("http://localhost:9090/note"); this.items = res.data.data; console.log(res.data.data); console.log(this.items.map(item => item.msg)); }, async delById(id) { await axios.delete("http://localhost:9090/note/" + id); this.getData(); }, }, created() { this.getData(); }, }; </script>
标签:axios,http,res,家庭,记账,items,getData,data From: https://www.cnblogs.com/daniel350-wang/p/18036186