2017-08-12 81 views
1

我有許多電報鍵盤在我火力地堡,我想童車特定鍵盤的用戶點擊,
msg.text是我的鍵盤的可變從火力地堡讀變量童車

const ref = db.ref('Keyboards/Keyboard1/childs'); //keyboard 1 
const ref = db.ref('Keyboards/Keyboard2/childs'); //keyboard 2 
const ref = db.ref('Keyboards/Keyboard3/childs'); //keyboard 3 

如何添加Keyboard[n],我的意思是msg.text在我的ref
如果我輸入msg.text是= Keyboard1我得到Keyboard1童車和...

它沒有工作

const ref = db.ref('Keyboards/msg.text/childs'); 

注意當我的項目是當地的本地JSON,我用下面的代碼爲此和Works Fine:
locale.keyboards[msg.text].childs

+1

您是否嘗試使用db.ref('Keyboards /'+ msg.text +'/ childs'); – hasan

+0

謝謝。解決 –

+0

歡迎:) – hasan

回答

2

您可以嘗試如下。

db.ref('Keyboards/' + msg.text + '/childs');