How to send msg.payload from function node to template node

孤街醉人 提交于 2021-02-05 06:43:27

问题


How to send msg.payload from function node(tool) to template node(html)?

<html>
<head>
    <script type="text/javascript">
    // function test() {
    //      document.getElementById("test1").innerHTML = msg.payload;
    // }
    </script>
</head>
<body onload="test()">
    <h1 id="test1">{{msg.payload}}</h1>
</body>


回答1:


The problem is you are using {{msg.payload}} in the template node. The values pulled in via mustache are keyed from the msg object. So the correct mustache template is {{payload}}.

<head>
    <script type="text/javascript">
    // function test() {
    //      document.getElementById("test1").innerHTML = {{payload}};
    // }
    </script>
</head>
<body onload="test()">
    <h1 id="test1">{{payload}}</h1>
</body>

The Info sidebar in Node-RED gives examples of what to use.



来源:https://stackoverflow.com/questions/42361699/how-to-send-msg-payload-from-function-node-to-template-node

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!