数据显示到页面js

.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;

}

// 数据

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;

  • 你可能感兴趣的:(数据显示到页面js)