1.index.html

  1. <td><a href="/doDelete?id={{@$value._id}}" type="button" class="btn btn-success">删除</a>

2.doDelete.js

  1. const Router = require("koa-router");
  2. const router = new Router();
  3. const ShopMangeModel = require("../models/shopMange");
  4. // 查询数据库
  5. router.get("/doDelete",async ctx=>{
  6. console.log(ctx.query)
  7. var {id} = ctx.query;
  8. await ShopMangeModel.deleteOne({_id:id});
  9. ctx.redirect("/")
  10. })
  11. module.exports = router;