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>
posted @ 2021-06-21 11:11  胡勇健  阅读(39)  评论(0)    收藏  举报