美文网首页
数据显示到页面js

数据显示到页面js

作者: 陈庆香 | 来源:发表于2018-07-31 17:47 被阅读0次

.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

        本文链接:https://www.haomeiwen.com/subject/kighvftx.html