请选择 进入手机版 | 继续访问电脑版
开启辅助访问
帐号登录 |立即注册

JS将字面量数组输出成列表

 
CSS样式表
<style>
ul {list-style: none;}
li {padding: 10px;}
li:nth-child(odd) {
background:  #16a085;
color:white ;
}
<style>

<script>
let lessons
=[
{ title : ”媒体查询响应式布局" },
{ title : "FLEX弹性盒模型” },
{ title : "GRID栅格系统" }
];
function template() {
return `
<ul>${ lessons .map( item =>` <li>${item. title}</ li>`). join("")}</ul>`;
}
document . body . innerHTML = template( );
</script>

回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则