0
我是新來的節點變紅了,我一直在試圖建立一個新變量之後的文檔http://nodered.org/docs/writing-functions.html
這裏的例子是代碼:如何從對象msg中檢索變量?
// initialise the counter to 0 if it doesn't exist already
var count = context.get('count')||0;
count += 1;
// store the value back
context.set('count',count);
// make it part of the outgoing msg object
msg.count = count;
return msg;
但後來我不得不使用變量msg麻煩。計數。我發出了一條消息,試圖通過多次嘗試打印該值,如{msg.count}
或{msg.get('count')}
,但它每次都寫入undefined
或者什麼都不寫。
如何打印變量數?
這就是流程的樣子,交換機只是檢查msg.count的值。
您需要解釋您嘗試訪問「msg.count」的位置。對你的流程(或屏幕截圖)的描述會有所幫助。 – hardillb