js访问jsion数据动态显示在html页面

一、jsion数据文件:fileList.js

 

var fileList = [{

name: 'aa',

size: '1.3M',

createTime: '2019-07-16 11:33',

url: './aa.doc',

remarks: '图片类型文件',

},{

name: 'bb',

size: '32.3M',

createTime: '2019-07-16 11:34',

url: './bb.doc',

remarks: 'Word类型文件',

},

{

name: 'cc',

size: '2.3K',

createTime: '2019-07-16 15:34',

url: './cc.doc',

remarks: 'Excel类型文件',

}];

 

 

二、html文件:index.html

 

<!DOCTYPE html>

<html lang="en">

<head>

  <meta charset="UTF-8">

  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">

<title>文件管理</title>

<link href="./home.css" rel="stylesheet" type="text/css" />

</head>

<body>

  <div id="app">

<h2>文件管理</h2>

<div>

<div class="file-title">

<span class="name-title">文件名</span>

<span class="size-title">大小</span>

<span class="createTime-title">日期</span>

<span class="remarks-title">备注</span>

</div>

<div class="file-content">

</div>

</div>

</div>

</body>

</html>

<script type="text/javascript" src="./js/jquery-3.4.1.js"></script>

<script type="text/javascript" src="./fileList.js"></script>

<script>

var strHtml = "\r\n";

for(var i = 0;i < fileList.length; i++){

strHtml += "<div class='contentList'>";

strHtml += "<img src='./images/fileLogos.jpg'>";

strHtml += "<span class='name'><a href="+ fileList[i].url +">"+ fileList[i].name + "</a></span>";

strHtml += "<span class='size'>"+ fileList[i].size + "</span>";

strHtml += "<span class='createTime'>" + fileList[i].createTime + "</span>";

strHtml += "<span class='remarks'>" + fileList[i].remarks + "</span></div>";

}

$(".file-content").append(strHtml);

</script>

 

 

三、css文件:home.css

 

#app{

width: 1200px;

margin: 0 auto;

}

.file-title{

border: 1px solid #dcdee2;

width: 1200px;

height: 60px;

line-height: 60px;

border-bottom: none;

}

.name-title{

/* border: 1px solid blue; */

display: inline-block;

width: 180px;

font-size: 18px;

font-weight: 600;

color: #17233d;

padding-left: 10px;

}

.size-title{

/* border: 1px solid blue; */

display: inline-block;

width: 180px;

font-size: 18px;

font-weight: 600;

color: #17233d;

padding-left: 10px;

}

.createTime-title{

/* border: 1px solid blue; */

display: inline-block;

width: 250px;

font-size: 18px;

font-weight: 600;

color: #17233d;

padding-left: 10px;

}

.remarks-title{

/* border: 1px solid blue; */

display: inline-block;

width: 250px;

font-size: 18px;

font-weight: 600;

color: #17233d;

padding-left: 10px;

}

.file-content{

border: 1px solid #dcdee2;

width: 1200px;

border-bottom: none;

}

/* .file-content span{

width: 220px;

} */

.name{

/* border: 1px solid darkmagenta; */

display: inline-block;

width: 155px;

color: #515a6e;

}

.size{

/* border: 1px solid darkblue; */

display: inline-block;

width: 150px;

color: #515a6e;

}

span.createTime{

/* border: 1px solid forestgreen; */

display: inline-block;

width: 290px;

color: #515a6e;

}

.remarks{

/* border: 1px solid forestgreen; */

display: inline-block;

width: 170px;

color: #515a6e;

}

a{

text-decoration: none;

font-size: 18px;

}

.line{

border: 0.5px solid #dcdee2;

width: 1200px;

margin-top: 10px;

}

img{

width: 40px;

height: 40px;

margin-left: 10px;

margin-right: 10px;

display: inline-block;

line-height: 30px;

/* border: 1px solid red; */

}

.contentList{

/* border: 1px solid red; */

line-height: 50px;

border-bottom: 1px solid #dcdee2;

display: flex;

align-items: center;

}

转载于:https://www.cnblogs.com/wangyuxue/p/11202197.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值