2-2 编程练习
来源:2-2 编程练习
慕移动4506339
2022-07-13 20:35:29
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>模版字符串</title> </head> <body> <div class="div1"></div> <script type="text/javascript"> let person = { name: "xiaoming", age: 18 } let elem = document.querySelector('.div1') elem.innerHTML = "He is <b>" + person.name + " </b> " + "and we wish to know his" + person.age + ".That is all<br>" elem.innerHTML=`he is ${person.name} and we wish to know his ${person.age} .That is all <br>` </script> </body> </html>
老师,麻烦帮忙看下 为什么显示不出来
1回答
imooc_慕慕
2022-07-14
同学你好,模板字符串中少写了<b></b>加粗标签,导致效果出不开,修改参考如下:
祝学习愉快~