mirror of
https://github.com/ruanyf/es6tutorial.git
synced 2024-04-21 12:32:22 +00:00
新建style.md
This commit is contained in:
@@ -535,11 +535,15 @@ tag`First line\nSecond line`
|
||||
|
||||
上面代码中,tag函数的第一个参数是一个数组`["First line\nSecond line"]`,这个数组有一个raw属性,等于`["First line\\nSecond line"]`,两者唯一的区别就是斜杠被转义了。
|
||||
|
||||
```javascript
|
||||
|
||||
function tag(strings) {
|
||||
console.log(strings.raw[0]);
|
||||
// "First line\\nSecond line"
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## String.raw()
|
||||
|
||||
String.raw方法,往往用来充当模板字符串的处理函数,返回字符串被转义前的原始格式。
|
||||
|
||||
Reference in New Issue
Block a user