【发布时间】:2021-12-22 22:08:49
【问题描述】:
我正在开发库存应用程序,并尝试在单击 delete 字体真棒图标时从 mongodb 中删除项目。
我查看了 MDN 文档本地库项目 link,但他们使用带有隐藏表单输入的专用路由来删除项目。我似乎无法弄清楚如何对 pug 文件进行编码,以便在单击图标时在类别控制器中触发删除路由。
Category_detail.pug
extends layout
block head
link(rel="stylesheet", href="/stylesheets/category_detail.css")
<script src="https://kit.fontawesome.com/abb39a57a2.js" crossorigin="anonymous"></script>
block content
h1 #{category.name}
table
thead
tr
th Item name
th Price
th Update
th Delete
tbody
each item in items
tr
td #{item.itemName}
td #{item.price}
td
//- Update iten details
a(href="#")
i(class="fas fa-edit")
td
//- Delete item
form(method="POST" action='')
div.form-group
input(type="hidden", name='itemid',required="true", value=item._id )
a()
i(class="fas fa-trash" type='submit')
//- a(href="#")
//- i(class="fas fa-trash")
如果您想查看任何其他文件,这是我的github
【问题讨论】: