|
[其他]
谁能告诉我为什么js写出数据后css不起作用
[复制链接]
代码:- <!doctype html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
- <title>test</title>
- <link rel="stylesheet" type="text/css" href="../css/api.css" />
- <link rel="stylesheet" type="text/css" href="../css/common.css" />
- <style type="text/css">
- body {width:100%;margin:0px;padding:0px;background:red;}
- .li {width:50%;
- height:200px;
- border:1px solid black;
- }
- img{width:45%;
- }
- </style>
- </head>
- <body>
-
-
- </body>
- <script type="text/javascript" src="../script/api.js"></script>
- <script>
- apiready = function(){
-
- api.showProgress();//显示加载进度框
- api.ajax({
- url:'http://*********',//如果地址访问不到会请求出错,请填写自己的接口地址
- method:'get',
- cache:'false',
- timeout:30,
- dataTpye:'json',
- },function(ret,err){
- api.hideProgress();//隐藏加载进度框
-
- if(ret){var html="";
- for(var i=0;i<ret.length;i++){
-
- html+='<div class="li"><br>'+'商品'+ret[i].title+'<br>'+'<img src="'+ret[i].img+'"><br>'+'原价'+ret[i].price+'<br>'+'现价'+ret[i].discount_price+'</div>';
-
- }
- document.write(html);
- }
- else{
- api.alert({msg:('错误码:'+err.code+';错误信息:'+err.msg+'网络状态码:'+err.statusCode)});
- }
- });
-
-
-
- api.setRefreshHeaderInfo({
- visible:true,
- bgColor:'#fff',
- textColor:'#ccc',
- textDown:'下拉刷新',
- textUp:'松开刷新',
- showTime:true,
-
- },function(ret,err){
- //coding...
- //读取数据
- //判断是否有更新
- //重新填充内容
-
- api.refreshHeaderLoadDone();
- }
- );
- };
- </script>
- </html>
复制代码
|
|