问题
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