【发布时间】:2022-08-12 00:47:25
【问题描述】:
我正在尝试在用于电子邮件的车把模板中使用图像。唯一的问题是图像没有显示。我尝试了几种方法来解决这个问题,但没有任何帮助。
main.ts 配置:
app.useStaticAssets(join(__dirname, \'..\', \'src\', \'static\'))
app.setBaseViewsDir(join(__dirname, \'..\', \'src\', \'static\', \'templates\'))
app.setViewEngine(\'hbs\')
文件夹结构:
-src
--static
---img
----image1.png
----image2.png
---templates
----email1.hbs
----email2.hbs
如何在模板中使用图像:
<img src=\"/static/img/logo.png\" alt=\"logo\">
在电子邮件中,它看起来像这样:
https://ci4.googleusercontent.com/proxy/IhSgHQ3zXQ7Wh6MMxDAzkCjjFuvjZF3OI_Ru5CEQg3dGnin7xXJdUfjVTIg8Ag=s0-d-e1-ft#http:///static/img/logo.png
-
从输出源字符串末尾的
http:///static/img/logo.png来看,您需要在URL 中包含主机名,如www.example.com/static/img/logo.png。
标签: handlebars.js nestjs