为什么我的静态方法值未出现在我的EJS页面中
模型
static status(){
this.count()
.then(data => {
return data;
})
}
这是从我想将静态状态()值的
我的控制器中
static home(req, res){
// console.log(req.query);
let title = req.query.title;
let artist = req.query.artist;
let temp = {};
if(title){
temp.name = {[Op.iLike]: '%' + title + '%'}
}else{
temp.name = {[Op.iLike]: '%' + '%'}
}
if(artist){
temp.artist = {[Op.iLike]: '%' + artist + '%'};
}else{
temp.artist = {[Op.iLike]: '%' + '%'}
}
// console.log(temp);
Art.findAll({
order: [['date', 'desc']],
where: {name: temp.name, artist: temp.artist}
})
.then(data => {
// console.log(data[0])
res.render('home', {
data,
Art,
});
})
.catch(err => {
res.send(err);
})
}
从我的EJS页面中获取的模型,这是在 <%= art.status()%>
this is from the models
static status(){
this.count()
.then(data => {
return data;
})
}
I wanna take the value of static status() to my ejs page
this is in my controller but when i run the code the value didn't appear
static home(req, res){
// console.log(req.query);
let title = req.query.title;
let artist = req.query.artist;
let temp = {};
if(title){
temp.name = {[Op.iLike]: '%' + title + '%'}
}else{
temp.name = {[Op.iLike]: '%' + '%'}
}
if(artist){
temp.artist = {[Op.iLike]: '%' + artist + '%'};
}else{
temp.artist = {[Op.iLike]: '%' + '%'}
}
// console.log(temp);
Art.findAll({
order: [['date', 'desc']],
where: {name: temp.name, artist: temp.artist}
})
.then(data => {
// console.log(data[0])
res.render('home', {
data,
Art,
});
})
.catch(err => {
res.send(err);
})
}
this is in my ejs page
<%= Art.status() %>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在
状态
中,您不会从异步count
调用返回值,您最好将此函数标记为异步:In
status
you don't return a value from an asynccount
call, you better mark this function as async and simply return value right fromcount
: