2016-06-09 68 views
2

我想弄清楚如何調用模板文本中的函數,並且似乎無法使其正常工作。我是新來的模板工作,所以必須有我不知道的東西。在es6模板文字中調用函數?

function test1(text) { 
    return text; 
} 

function test2(text) { 
    return text; 
} 

function finalTest() { 
    console.log(`This is test1('hi there') and test2('hi again')`); 
} 

finalTest(); 

回答

1

就把它們在大括號一樣要處理的JavaScript的其他表情:

console.log(`This is ${test1('hi there')} and ${test2('hi again')}`); 
+0

太棒了。謝謝 – pertrai1