当我们添加mqtt-in或mqtt-out节点时,我们获得一个带有选择列表的服务器字段和一个可以将新服务器添加到列表中的按钮。
请,帮助我用铅笔而不是默认更改按钮的功能。
答案 0 :(得分:1)
This is what's known as a config node, how to create config nodes is described in the Node-RED documentation here: https://nodered.org/docs/creating-nodes/config-nodes
The important bit is the type of the of the config option:
<script type="text/javascript">
RED.nodes.registerType('mqtt in',{
category: 'input',
defaults: {
name: {value:""},
topic: {value:"",required:true,validate: RED.validators.regex(/^(#$|(\+|[^+#]*)(\/(\+|[^+#]*))*(\/(\+|#|[^+#]*))?$)/)},
qos: {value: "2"},
broker: {type:"mqtt-broker", required:true}
},
color:"#d8bfd8",
inputs:0,
outputs:1,
...
As you can see the broker
field has a type of mqtt-broker
. The mqtt-broker
node is a separate node with a category of config
.
There are plenty of examples of this type of pattern in the core nodes that ship with Node-RED including the MQTT or serial port nodes.