Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 使用pug从mongo atlas渲染图像_Node.js_Mongodb_Pug - Fatal编程技术网

Node.js 使用pug从mongo atlas渲染图像

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)

我是一名学习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);
   }   
})

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