节点红色仪表板包含图像

我正在使用node-red创build应用程序,并使用node-red-dashboard创buildui。

我已经包含了一些API调用,并基于我想更改模板控件的图像源的响应。

<img src="/home/pi/Destkop/WeatherImages/sun.png">

所以我使用了图像的绝对path。 但图像没有被加载。 有一个符号,表示图像的来源被设置为localhost:1880/sun.png

我在哪里需要放置图像? 我需要使用什么path?

您不能使用本地path从内置于Node-RED的Web服务器提供的文件,因为访问该页面的浏览器可能不在运行Node-RED的同一台机器上。

settings.js文件(它将在〜/ .node-red)中有一个名为httpStatic的设置,你可以使用它来指定一个目录,Node-RED将服务器上的静态内容。

 ... // When httpAdminRoot is used to move the UI to a different root path, the // following property can be used to identify a directory of static content // that should be served at http://localhost:1880/. //httpStatic: '/home/nol/node-red-static/', ... 

如果您将其设置为/ home / pi / Destkop / WeatherImages,如下所示:

 ... // When httpAdminRoot is used to move the UI to a different root path, the // following property can be used to identify a directory of static content // that should be served at http://localhost:1880/. httpStatic: '/home/pi/Desktop/WeatherImages', ... 

你可以设置图像的src如下:

 <img src="/sun.png">