es6 模板字符串
模板字符串
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>模板字符串</title>
</head>
<body>
<script>
//声明
let str = `字符串`;
console.log(str, typeof str);
//2 内容可以有换行符
let ul = `<ul>
<li>li1</li>
<li>li2</li>
</ul>`;
console.log(ul);
//3 变量拼接
let name = '小明';
let string = `${name} 是小学生`;
console.log(string);
</script>
</body>
</html>

浙公网安备 33010602011771号