2016-12-01 45 views
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的值。

enter image description here

+0

您需要解釋您嘗試訪問「msg.count」的位置。對你的流程(或屏幕截圖)的描述會有所幫助。 – hardillb

回答

0

我想的太複雜了。
我只需要使用{count}而不是{msg.count}