Я должен использовать глобальные переменные или переменные, постоянные для потока, и у меня возникают проблемы в некоторых случаях: все нормально, когда я использую его в простой функции, у меня есть хорошее возвращаемое сообщение с хорошим vakue (используя .set или .get), ноКогда я пытаюсь получить переменную в сценарии, чтобы отправить ее на HTML-страницу, это не работает! (используя тот же синтаксис)
Идея? Мой узел-красный ниже
[{"id":"1aed4db1.318612","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"8165070c.f8bec8","type":"template","z":"1aed4db1.318612","name":"html","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<!DOCTYPE html>\n<html>\n <head>\n <meta charset=\"utf-8\"/>\n \n \n </head>\n <body onload=\"draw();\">\n <canvas id=\"canvas\" width=\"500\" height=\"500\"></canvas>\n <script>{{{payload.draw}}}</script>\n </body>\n</html>\n\n\n\n","output":"str","x":410,"y":200,"wires":[["e46f2202.f0adb"]]},{"id":"6460da00.6d5c68","type":"http in","z":"1aed4db1.318612","name":"","url":"/test","method":"get","upload":false,"swaggerDoc":"","x":60,"y":200,"wires":[["6d9dba5b.d5a514"]]},{"id":"e46f2202.f0adb","type":"http response","z":"1aed4db1.318612","name":"","statusCode":"","headers":{},"x":630,"y":200,"wires":[]},{"id":"94994060.2fe75","type":"debug","z":"1aed4db1.318612","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":500,"y":140,"wires":[]},{"id":"9a0d36a3.66cc08","type":"function","z":"1aed4db1.318612","name":"","func":"total=flow.get(\"test\");\nmsg.payload=total;\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":140,"wires":[["94994060.2fe75"]]},{"id":"d76ddfb4.1bee6","type":"inject","z":"1aed4db1.318612","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":80,"y":140,"wires":[["9a0d36a3.66cc08"]]},{"id":"946553b2.76d2f","type":"config","z":"1aed4db1.318612","name":"","properties":[{"p":"test","pt":"flow","to":"\"essai\"","tot":"str"}],"active":true,"x":90,"y":80,"wires":[]},{"id":"6d9dba5b.d5a514","type":"template","z":"1aed4db1.318612","name":"Draw","field":"payload.draw","fieldType":"msg","format":"handlebars","syntax":"mustache","template":" function draw() {\n var canvas = document.getElementById(\"canvas\");\n var ctx2 = canvas.getContext(\"2d\");\n ctx2.fillStyle = 'red';\n ctx2.fillRect(10, 10, 50, 50);\n ctx2.fillText(flow.get(\"test\"),200,20);\n }\n","output":"str","x":210,"y":200,"wires":[["8165070c.f8bec8"]]}]