我正在使用JavaScript ES6 医生来了的新模板文本(模板字符串)语法,并且我不太确定如何转义用于拆分字符串以添加参数的美元符号。
以下是我要做的事:
var response = `I consent to my credit card being charged in the amount of
$ ${ total } for the purchase of ${ item.title } and any
applicable sales tax.`效果很好..。但我真的不想有那个空间$ ${title}
这样做的最终结果如下:
..。一共25.99美元.
我真的更希望
..。一共25.99美元.
我想这是可以的,或者很明显,我可以使用旧的方式,仍然有效,但很高兴知道如何解决这个问题。我链接到Mozilla文档,在里面找不到任何东西,希望有人知道如何解决这个问题。
发布于 2016-06-26 22:16:33
var response = `I consent to my credit card being charged in the amount of
$${ total } for the purchase of ${ item.title } and any
applicable sales tax.`https://stackoverflow.com/questions/38043686
复制相似问题