节点红色仪表板包含图像
Node Red Dashboard Include Images
我正在使用 node-red
创建应用程序并使用 node-red-dashboard
创建 ui。
我已经包含了一些 api 调用,并根据响应更改模板控件的图像源。
<img src="/home/pi/Destkop/WeatherImages/sun.png">
所以我使用了图片的绝对路径。但是图片没有加载。有一个符号表示图像的来源设置为 localhost:1880/sun.png
。
我需要把图片放在哪里?我需要使用什么路径?
您不能对 Node-RED 内置网络服务器提供的文件使用本地路径,因为访问该页面的浏览器可能与 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">
我正在使用 node-red
创建应用程序并使用 node-red-dashboard
创建 ui。
我已经包含了一些 api 调用,并根据响应更改模板控件的图像源。
<img src="/home/pi/Destkop/WeatherImages/sun.png">
所以我使用了图片的绝对路径。但是图片没有加载。有一个符号表示图像的来源设置为 localhost:1880/sun.png
。
我需要把图片放在哪里?我需要使用什么路径?
您不能对 Node-RED 内置网络服务器提供的文件使用本地路径,因为访问该页面的浏览器可能与 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">