我想以列表的形式显示数据库中的所有医生,我不知道如何在pug中使用列表,我如何显示每个医生的医生信息,我到达的地方,请提供任何帮助,我应该编辑或添加什么
app.get("/user/new_diagnosis",checkNotAuthenticated,(req, res) => {
res.render("user-diagnosis",{ name: req.user.userName ,surname: req.user.userSurname });
db.query(
`SELECT * FROM doctor`,
(err, results) => {
if (err) {
console.log(err);
}
const Ndoc = results;
console.log(results);
}
);
});
console.log(结果);产出
[
RowDataPacket {
doctorID: 1,
hospitalName: 'momi',
doctorName: 'adam',
doctorSurname: 'rakii',
doctorEmail: 'adam.rakii@gmail.com',
doctorPassword: 'riro',
created_at: null,
updated_at: null
},
RowDataPacket {
doctorID: 2,
hospitalName: 'hopi',
doctorName: 'hajar',
doctorSurname: 'rako',
doctorEmail: 'hajar.hu@gmail.com',
doctorPassword: 'dsj',
created_at: null,
updated_at: null
}
]
extends user-layout
block content
div.container-fluid
div(class=["row", "pt-4"])
div(class=["col-md-3", "col-sm-5", "d-md-flex", "flex-column", "border-end"])
h3(class=["text-black", "py-4", "text-center"]) Select A Doctor
form.d-flex.mb-3(role="form", action="/", method="get")
input.form-control.me-2(id="doctor-search", name="doctor-search", type='search' placeholder='Search' aria-label='Search')
button.btn.btn-outline-success(type='submit') Search
- var doctor_number = [1, 2, 3, 4 ,5, 6, 7, 8, 9, 10];
each val in doctor_number
.list-group
a.list-group-item.list-group-item-action.d-flex.gap-3.py-3(href= `new_diagnosis/${val}`, aria-current='true')
svg(xmlns="http://www.w3.org/2000/svg", width="50", height="50", fill="currentColor", class=["bi", "bi-person-circle", "pe-1"], viewBox="0 0 16 16")
path(d="M11 6a3 3 0 1 1-6 0 3 3 0 0 1 6 0z")
path(fill-rule="evenodd", d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8zm8-7a7 7 0 0 0-5.468 11.37C3.242 11.226 4.805 10 8 10s4.757 1.225 5.468 2.37A7 7 0 0 0 8 1z")
.d-flex.gap-2.w-100.justify-content-between
div
h6.mb-0= "Doctor "+ val
p.mb-0.opacity-75 Some placeholder content in a paragraph.
small.opacity-50.text-nowrap now
div(class=["col-md-9", "col-sm-7", "px-4"])
//-form(role="form", action="examination_card", method="post")
ul
each val in myArr
li= val
确保从后端正确发送数据。可以使用数据[0]访问该数组。doctorName
适用于您的案例:
res.render("user-layout",doctors);
帕格:
ul
each doctor in doctors
li= doctor
关于这个的更多信息:帕格中的迭代