1
0
mirror of https://github.com/ruanyf/es6tutorial.git synced 2025-05-24 10:22:23 +00:00

docs(string): add an example of template string

This commit is contained in:
ruanyf 2016-10-18 13:12:39 +08:00
parent c46a4ef8b5
commit b2b00c29d0

View File

@ -837,6 +837,15 @@ HelloWorldApp.main();
模板处理函数的第一个参数(模板字符串数组),还有一个`raw`属性。
```javascript
console.log`123`
// ["123", raw: Array[1]]
```
上面代码中,`console.log`接受的参数,实际上是一个数组。该数组有一个`raw`属性,保存的是转义后的原字符串。
请看下面的例子。
```javascript
tag`First line\nSecond line`