快速车把 |我如何获得地图值
express handlebars | how I get the map value
controller.js
Settings.find()
.then((result) => {
for(const key in result){
const map = new Map();
map.set(result[key].key,result[key].value);
}
}).catch((err) => {
console.log(err);
});
res.render('admin/settings', {
data : this.map
});
如何发送地图值以供查看?我该怎么办?
view.js
<input class="form-control" type="text" name="config_site_title" value="config_site_title">
解决方案
const getIndex = async (req, res, next) => {
Settings.find()
.then((result) => {
for(const key in result){
const data = new Array();
data.push(result[key].key,result[key].value);
console.log(data);
res.render('admin/settings', {
pageDetails: {
title: "Yönetim Paneli - Ayarlar",
},
data : data
});
}
}).catch((err) => {
console.log(err);
});
controller.js
Settings.find()
.then((result) => {
for(const key in result){
const map = new Map();
map.set(result[key].key,result[key].value);
}
}).catch((err) => {
console.log(err);
});
res.render('admin/settings', {
data : this.map
});
如何发送地图值以供查看?我该怎么办?
view.js
<input class="form-control" type="text" name="config_site_title" value="config_site_title">
解决方案
const getIndex = async (req, res, next) => {
Settings.find()
.then((result) => {
for(const key in result){
const data = new Array();
data.push(result[key].key,result[key].value);
console.log(data);
res.render('admin/settings', {
pageDetails: {
title: "Yönetim Paneli - Ayarlar",
},
data : data
});
}
}).catch((err) => {
console.log(err);
});