【问题标题】:How to send msg.payload from function node to template node如何将 msg.payload 从功能节点发送到模板节点
【发布时间】:2017-02-21 08:02:00
【问题描述】:

如何将msg.payload从函数节点(工具)发送到模板节点(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>

【问题讨论】:

  • 如果你在函数节点中包含你已经拥有的东西会有所帮助
  • @hardillb 对不起,我没有在函数节点中得到你,我这样写 msg.payload = "hello";返回味精;
  • 编辑问题以包含函数节点中的所有代码
  • 在函数节点,我这样写 msg.payload = "hello";返回味精

标签: node-red


【解决方案1】:

问题是您在模板节点中使用{{msg.payload}}。通过 mustache 提取的值来自 msg 对象。所以正确的小胡子模板是{{payload}}

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

Node-RED 中的 Info 侧边栏提供了使用示例。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-09-26
    • 2011-01-12
    • 2013-04-26
    • 1970-01-01
    • 1970-01-01
    • 2022-01-02
    • 2019-01-05
    • 2021-08-22
    相关资源
    最近更新 更多