模板文字标签功能与变量?

时间:2017-02-03 18:14:50

标签: javascript template-literals

是否可以将已赋值模板文字值的变量传递给函数,然后该函数使用函数调用它?

示例:

function strLiteralProcessor(str){
     console.log(str);
     return //what goes here? I want to call the tag function myTagFunc with str, but myTagFuncstr is obviously wrong.
};

var name = prompt("What's your name?");
strLiteralProcessor(`Hi, ${name}!`);

我会做myTagFunc(str)之类的事情,还是我错过了什么?

0 个答案:

没有答案