.list {
border: 1px solid green;
width: 300px;
margin: 0;
padding: 0;
}
.item {
border-bottom: 1px solid #999;
width: 300px;
height: 60px;
text-align: center;
list-style: none;
line-height: 60px;
}
// 數(shù)據(jù)
var txl = [
{username: '王飛鴿',age: 18},
{username: '鄒忠',age: 18},
{username: '張三',age: 28},
{username: '李四',age: 100},
{username: '王五',age: 1000}
];
var htmlStr = '';
for (var i=0;i
htmlStr +=
`
用戶名: ${txl[i].username}
年齡: ${txl[i].age}
`;
}
console.log(htmlStr);
document.querySelector('.list').innerHTML = htmlStr;