完整效果
首先渲染把头部和尾部渲染到页面中
渲染头部document.write(`<table> <caption>学生详细信息</caption><tr><th>序号</th><th>姓名</th><th>年龄</th><th>性别</th><th>地址</th></tr>`)
把数据声明存放过来let students = [{name:'李晓',age:18,sex:'女',hometown:'四川省'},{name:'刘磊',age:28,sex:'男',hometown:'河北省'},{name:'李冰冰',age:16,sex:'女',hometown:'北京省'},{name:'安然',age:13,sex:'女',hometown:'湖南省'},{name:'邓宇',age:20,sex:'男',hometown:'天津省'}];因为是循环数组里大的对象所以要用for循环,利用for循环遍历数组里面的数据并渲染到页面for (let i=0; i<students.length;i++){document.write(`<tr><th>${ i + 1}</th><th>${students[i].name}</th><th>${students[i].age}</th><th>${students[i].sex}</th><th>${students[i].hometown}</th></tr>`)}渲染尾部document.write (`</table> `)