node.js实现图书增删改查

本文档介绍了如何使用Node.js来实现图书管理系统的增删改查功能。通过分析需求,安装相关依赖如express-art-template,创建并编辑views文件中的index.art、editBook.art和addBook.art,以及新建public文件夹和样式文件style.css。同时,涉及的js文件包括index.js、router.js和service.js,最终成功实现了图书管理系统的功能。
摘要由CSDN通过智能技术生成

实现图书的增删改查

1.分析
在这里插入图片描述
2.文件

  1. 生成json文件包
F:\others\XAMPP\htdocs\Epr\mybook>npm init -y
Wrote to F:\others\XAMPP\htdocs\Epr\mybook\package.json:

{
  "name": "mybook",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}
  1. 安装依赖包
F:\others\XAMPP\htdocs\Epr\mybook>cnpm install express art-template body-parser --save
  1. 安装模板引擎express-art-template
F:\others\XAMPP\htdocs\Epr\mybook>express art-template
  1. 添加文件
    在这里插入图片描述

  2. 在views文件添加index.art文件:
    views文件新建:editBook.art,addBook.art

<div class="title">图书管理<a href="#">添加图书</a></div>
		<div class="content">
			<table>
				<thead>
					<tr>
						<th>编号</th>
	                    <th>名称</th>
	                    <th>作者</th>
	                    <th>分类</th>
	                    <th>描述</th>
	                    <th>操作</th>
					</tr>
				</thead>
					 <tbody>
	              		  {
  {each list}}
	               			 <tr>
			                    <td>{
  {$value.id}}</td>
			                    <td>{
  {$value.name}}</td>
			                    <td>{
  {$value.author}}</td>
			          
  • 0
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值