图书管理前端页面
1.图书管理页面
1.1 http/apis.js 添加后端请求路由
import { get, post, put, del } from './index'
// 书籍管理接口
export const getBookList = (params, headers) => get("/books/book/", params,
headers)
export const addBook = (params, headers) => post("/books/book/", params, headers)
export const editBook = (params, headers) => put("/books/book/", params, headers)
export const delBook = (params, headers) => del("/books/book/", params, headers)
1.2 router/index.js 添加路由
import Books from '@/views/books/Books'
export default new Router({
routes: [
{ path: '/', name: 'Books', component: Books }, // 图书增删改查
案例
]
})
1.3 src\views\books\Books.vue 父组件
<template>
<div>
<h1>图书管理系统</h1>
<div style="margin: 30px;">
<button @click="addNew">新增图书</button>
<BookEdit
v-show='dialogVisible'
:visible.sync='dialogVisible'
:data='editData'
@save='save'
></BookEdit>
</div>
<div>
<table style='margin: auto; border: solid 1px black;'>
<tr>
<th>图书编号</th>
<th>图书名字</th>
<th>出版时间</th>
<th>阅读数</th>
<th>评论数</th>
<th>操作</th>
</tr>
<tr
v-for="(book, index) in books"
:key="book.id"
>
<td>{{book.id}}</td>
<td>{{book.btitle}}</td>
<td>{{book.bpub_date}}</td>
<td>{{book.bread}}</td>
<td>{{book.bcomment}}</td>
<td>
<button @click="edit(index)">修改</button>
<button @click="del(index)">删除</button>
</td>
</tr>
</table>
</div>
</div>
</template>
<script>
import { getBookList, addBook, editBook, delBook } from '@/http/apis'