利用node.js搭建一个后台管理系统
2022-08-03 09:57:03
197
{{single.collect_count}}

利用node.js 实现一个后台管理系统。node.js 常用框架express、koa。此项目用koa。

步骤

第一步:全局安装node.js
第二步:在本地建立项目目录。
第三步:安装本地依赖:npm i koa koa-views koa-static koa-router koa-body pug -S

第四步:项目启用:nodemon app.js
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

项目实现的功能:

新闻列表的展示

  • 分页功能
  • 点击单条展示页可以跳转到详情页
  • 新闻的上传

需要注意的地方:

  • 视图层用的pug模版,因此要把html转换为pug格式,抓换方式https://html2jade.org/
  • pug 模板里面,’|’ 表示转义
  • 因为是异步的,这里需要用到aysnc await
  • 注意form表单的enctype
  • node.js 上传的使用

源码

https://github.com/sunshine5856/newList/tree/hqq

回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}