Node.js 使用pug从mongo atlas渲染图像
我是一名学习nodejs的初学者,我想知道使用Node.js 使用pug从mongo atlas渲染图像,node.js,mongodb,pug,Node.js,Mongodb,Pug,我是一名学习nodejs的初学者,我想知道使用pug和multer从mongo atlas检索或渲染图像的正确方法,因为我被卡住了 const storage=multer.diskStorage({ destination:function(req,file,cb){ cb(null,"images"); }, filename:function(req,file,cb){ cb(null,"-"+Date.now()+file.originalname)
pug
和multer
从mongo atlas检索或渲染图像的正确方法,因为我被卡住了
const storage=multer.diskStorage({
destination:function(req,file,cb){
cb(null,"images");
},
filename:function(req,file,cb){
cb(null,"-"+Date.now()+file.originalname);
}
})
const upload=multer({storage:storage});
我将目标文件夹作为图像,将pug img src作为
img(src="/images/#{result.pic}").
但似乎不起作用,因为属性中不再支持{foo}
插值语法
而不是使用-
img(src='/images/#{result.pic}') // no longer supported
-您可以使用:
img(src='/images/' + result.pic) // supported
或者,如果您有ES6支持,您可以使用:
img(src='/images/' + result.pic) // supported
img(src=`/images/${result.pic}`) // supported