"# \u81ea\u5b9a\u4e49node-red\u8282\u70b9\u4e2d\uff0c\u5982\u4f55\u7f16\u5199\u8282\u70b9\u914d\u7f6e\u4fe1\u606f\u5f39\u7a97\n\n> 2023-03-25 | 2023-04-05\n> https:\/\/www.modbus.cn\/en\/11944.html\n\n**Node-RED**\n\n---\n\n## \u524d\u8a00\n\n\u6700\u8fd1\u6709\u8bfb\u8005\u901a\u8fc7\u535a\u5ba2\u5411\u6211\u54a8\u8be2\uff0c\u5728\u81ea\u5b9a\u4e49node-red\u8282\u70b9\u65f6\uff0c\u5982\u4f55\u7f16\u5199\u8be5\u8282\u70b9\u7684\u914d\u7f6e\u9875\u9762\uff0c\u5c31\u662f\u6211\u4eec\u901a\u5e38\u89c1\u5230\u7684\uff0c\u53cc\u8282\u8282\u70b9\u6253\u5f00\u7684\u4fe1\u606f\u5f39\u7a97\u3002\u5982\u4e0b\u56fe\uff1a\n\n![](https:\/\/image.modbus.cn\/wp-content\/uploads\/2023\/03\/1679739588-image-950x1222.png)\n\n![](https:\/\/image.modbus.cn\/wp-content\/uploads\/2023\/03\/1679739605-image-950x1204.png)\n\n\u4e0a\u9762\u4e24\u5f20\u56fe\uff0c\u5c55\u793a\u4e86inject\u8282\u70b9\u4e0emqtt in \u8282\u70b9\u7684\u914d\u7f6e\u5f39\u7a97\u3002\n\u5728\u5f39\u7a97\u4e2d\uff0c\u9664\u4e86\u4e0a\u9762\u7684\u5220\u9664\uff0c\u53d6\u6d88\uff0c\u5b8c\u6210\uff0c\u548c\u4e0b\u9762\u7684\u5931\u6548\u6309\u94ae\u3002\n\u4e2d\u95f4\u90e8\u5206\u90fd\u662f\u9700\u8981\u5f00\u53d1\u8005\u81ea\u5df1\u7f16\u5199\u7684\u3002\n\u4f60\u9700\u8981\u4ec0\u4e48\u6309\u94ae\uff0c\u9700\u8981\u54ea\u4e9b\u8f93\u5165\u6846\uff0c\u8fd8\u6709\u6587\u672c\u57df\u3002\n\n\u8282\u70b9\u914d\u7f6e\u5f39\u7a97\u662f\u7528\u6237\u914d\u7f6e\uff0c\u4fee\u6539\u8282\u70b9\u914d\u7f6e\u6570\u636e\u7684\u4e3b\u8981\u65b9\u5f0f\u3002\n\n\u4e0b\u9762\u5c31\u6559\u5927\u5bb6\u5982\u4f55\u7f16\u5199\u8fd9\u90e8\u5206\u7684\u9875\u9762\n\u914d\u7f6e\u5f39\u7a97\u662f\u7f16\u5199\u5728 \u8282\u70b9\u7684html \u6587\u4ef6\u91cc \u5e76\u4e14\u5199\u5728\n\n```\n&lt;script type=&quot;text\/html&quot; data-template-name=&quot;node-type&quot;&gt;\n    &lt;!-- edit dialog content  --&gt;\n&lt;\/script&gt;\n```\n\n\u6ce8\u610fscript\u6807\u7b7e\u7684 type\u5c5e\u6027 \u5fc5\u987b\u914d\u7f6e\u4e3a text\/html\uff0c\u8fd9\u80fd\u591f\u5e2e\u52a9\u7f16\u8f91\u5668\u9ad8\u4eae\u8bc6\u522bjs\u8bed\u6cd5\u3002\n\u6807\u7b7e\u8fd8\u5e94\u8be5\u5305\u542bdata-template-name \u5c5e\u6027\uff0c\u8868\u9762\u8be5\u811a\u672c\u662f\u5e94\u7528\u4e8e\u90a3\u4e2a\u8282\u70b9\u7c7b\u578b\u3002\n\u4f60\u53ef\u4ee5\u5728\u8fd9\u91cc\u7f16\u5199html,\n\u5982\u4e0b\uff1a\n\n```\n&lt;div class=&quot;form-row&quot;&gt;\n    &lt;label for=&quot;node-input-name&quot;&gt;&lt;i class=&quot;fa fa-tag&quot;&gt;&lt;\/i&gt; Name&lt;\/label&gt;\n    &lt;input type=&quot;text&quot; id=&quot;node-input-name&quot; placeholder=&quot;Name&quot;&gt;\n&lt;\/div&gt;\n\n```\n\n\u4ee5\u4e0a\u662f\u4e00\u4e2a\u7528\u4e8e\u8f93\u5165\u540d\u5b57\u7684\u8f93\u5165\u6846\u3002\u6709\u4e9bclass\u662f\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u5b98\u65b9\u7684\uff0c\u6bd4\u5982form-row \uff0c\u8be5class\u4f1a\u5e2e\u4f60\u521b\u5efa\u4e00\u4e2a\u5757\u7ea7\u5143\u7d20\uff0c\u5c06\u4fe1\u606f\u5c55\u793a\u4e00\u884c\u4e00\u884c\u5730\u5c55\u793a\u3002\n\n\u9664\u4e86\u5f00\u53d1\u8005\u81ea\u5df1\u7f16\u5199css \u548c html\uff0cnode-red\u5b98\u65b9\u4e5f\u63d0\u4f9b\u4e86\u4e00\u4e9b\u6807\u51c6\u7684\u7ec4\u4ef6\u4f9b\u5927\u5bb6\u4f7f\u7528\u3002\n\u4f7f\u7528\u4ed6\u4eec\u7f16\u5199\u8282\u70b9\u914d\u7f6e\u5f39\u7a97\uff0c\u4f1a\u66f4\u7f8e\u89c2\uff0c\u7b80\u7ea6\uff0c\u4e5f\u4f1a\u5f88\u7b26\u5408node-red\u7684\u6574\u4f53\u98ce\u683c\u3002\n\u4e0b\u9762\u4e00\u8d77\u6765\u770b\u4e00\u4e0b\u3002\n\n## \u6309\u94ae\n\n\u7531\u4e8e\u6309\u94ae\u7ecf\u5e38\u88ab\u7528\u5230\uff0c\u6240\u6709\u5b98\u65b9\u63d0\u4f9b\u4e86\u4e00\u5957\u6807\u51c6\u7684\u6309\u94ae\u7ec4\u4ef6\u3002\n\u4f60\u53ef\u4ee5\u8fd9\u6837\u4f7f\u7528\n\n```\n&lt;button type=&quot;button&quot; class=&quot;red-ui-button&quot;&gt;Button&lt;\/button&gt;\n&lt;button type=&quot;button&quot; class=&quot;red-ui-button red-ui-button-small&quot;&gt;Button&lt;\/button&gt;\n&lt;span class=&quot;button-group&quot;&gt;\n&lt;button type=&quot;button&quot; class=&quot;red-ui-button toggle selected my-button-group&quot;&gt;b1&lt;\/button&gt;&lt;button type=&quot;button&quot; class=&quot;red-ui-button toggle my-button-group&quot;&gt;b2&lt;\/button&gt;&lt;button type=&quot;button&quot; class=&quot;red-ui-button toggle my-button-group&quot;&gt;b3&lt;\/button&gt;\n&lt;\/span&gt;\n\n```\n\n\u4ee5\u4e0a\u4ee3\u7801\u7684\u663e\u793a\u6309\u94ae\n\n![](https:\/\/image.modbus.cn\/wp-content\/uploads\/2023\/03\/1679739641-image.png)\n\n## \u8f93\u5165\u6846\n\n\u5982\u679c\u4f60\u8981\u4f7f\u7528\u8f93\u5165\u6846\u7684\u8bdd\uff0c\u53ef\u4ee5\u770b\u770b\u5b98\u65b9\u63d0\u4f9b\u7684\u6848\u4f8b\n\n```\nPlain HTML Input\n&lt;input type=&quot;text&quot; id=&quot;node-input-name&quot;&gt;\n\nTypedInput\nString\/Number\/Boolean\n&lt;input type=&quot;text&quot; id=&quot;node-input-example1&quot;&gt;\n&lt;input type=&quot;hidden&quot; id=&quot;node-input-example1-type&quot;&gt;\n\nTypedInput\nJSON\n&lt;input type=&quot;text&quot; id=&quot;node-input-example2&quot;&gt;\n\nTypedInput\nmsg\/flow\/global\n&lt;input type=&quot;text&quot; id=&quot;node-input-example3&quot;&gt;\n&lt;input type=&quot;hidden&quot; id=&quot;node-input-example3-type&quot;&gt;\n\n```\n\n![](https:\/\/image.modbus.cn\/wp-content\/uploads\/2023\/03\/1679739668-image.png)\n\n![](https:\/\/image.modbus.cn\/wp-content\/uploads\/2023\/03\/1679739681-image.png)\n\n\u5982\u679c\u4f60\u8981\u4f7f\u7528\u9009\u62e9\u6846\n\n```\n&lt;input type=&quot;text&quot; id=&quot;node-input-example5&quot;&gt;\n$(&quot;#node-input-example5&quot;).typedInput({\n    types: [\n        {\n            value: &quot;fruit&quot;,\n            multiple: &quot;true&quot;,\n            options: [\n                { value: &quot;apple&quot;, label: &quot;Apple&quot;},\n                { value: &quot;banana&quot;, label: &quot;Banana&quot;},\n                { value: &quot;cherry&quot;, label: &quot;Cherry&quot;},\n            ]\n        }\n    ]\n})\n\n```\n\n\u5b83\u5c31\u4f1a\u8868\u73b0\u6210\u8fd9\u6837\u5b50\u3002\n\n## \u591a\u884c\u6587\u672c\u57df\n\n\u5728node-red\u4e2d\u591a\u884c\u6587\u672c\u57df\u5176\u5b9e\u90fd\u662f \u4f7f\u7528\u7684\u4ee3\u7801\u7f16\u8f91\u5668\uff0c\u4f7f\u7528monaco\u6216\u8005ace\n\u4f60\u53ef\u4ee5\u8fd9\u6837\u4f7f\u7528\n\n```\n&lt;div style=&quot;height: 250px; min-height:150px;&quot; class=&quot;node-text-editor&quot; id=&quot;node-input-example-editor&quot;&gt;&lt;\/div&gt;\n\n```\n\n```\n\/\/ \u4f7f\u7528RED.editor.createEditor \u65b9\u6cd5\u521b\u5efa\u7f16\u8f91\u5668\uff0c\nthis.editor = RED.editor.createEditor({\n   id: 'node-input-example-editor',\n   mode: 'ace\/mode\/text',\n   value: this.exampleText\n});\n\n```\n\n```\n\/\/ \u5728\u4fdd\u5b58\u6216\u53d6\u6d88\u65f6\uff0c\u9500\u6bc1\u65e0\u7528\u7684\u5bf9\u8c61\uff0c\u91ca\u653e\u8d44\u6e90\noneditsave: function() {\n    this.exampleText = this.editor.getValue();\n    this.editor.destroy();\n    delete this.editor;\n},\noneditcancel: function() {\n    this.editor.destroy();\n    delete this.editor;\n},\n\n```\n\n\u7f16\u8f91\u5668\u6548\u679c\n\n![](https:\/\/image.modbus.cn\/wp-content\/uploads\/2023\/03\/1679739733-image-950x494.png)\n\n## \u603b\u7ed3\n\nnode-red\u63d0\u4f9b\u7684\u81ea\u5b9a\u4e49\u8282\u70b9\u529f\u80fd\uff0c\u8ba9\u6211\u4eec\u53ef\u4ee5\u81ea\u7531\u5730\u5236\u4f5c\u5404\u79cd\u5404\u6837\u7684\u8282\u70b9\u6765\u6ee1\u8db3\u81ea\u5df1\u7684\u9700\u8981\u3002\n\u4e4b\u524d\u6709\u4e2a\u8bfb\u8005\u8bf4\u4ed6\u4eec\u8981\u5728node-red\u4e2d\u505a\u76f4\u64ad\u4f1a\u8bae\u7cfb\u7edf\uff0c\u975e\u5e38\u4f69\u670d\u8fd9\u4e9b\u4eba\u7684\u521b\u9020\u529b\u3002\n\u8981\u60f3\u66f4\u5feb\uff0c\u66f4\u597d\u5730\u5f00\u53d1\u51fa\u597d\u7528\u7684\u8282\u70b9\uff0c\u9700\u8981\u628a\u57fa\u672c\u529f\u6253\u597d\uff0c\u4e07\u4e08\u5927\u697c\u5148\u628a\u5730\u57fa\u6253\u597d\u3002\u4f60\u5b66\u4f1a\u5566\u5417\uff1f\n\nMarkdown&nbsp;2920&nbsp;\u5b57\u6570&nbsp;130&nbsp;\u884c\u6570&nbsp;\u5f53\u524d\u884c 129, \u5f53\u524d\u5217 36&nbsp;\u6587\u7ae0\u5df2\u4fdd\u5b5818:18:05\n\n---\n*modbus.cn*\n"