\r\n\t\t
  • \"text/css\"
  • \r\n\t\t
  • * { 
  • \r\n\t\t
  •     padding:0px; 
  • \r\n\t\t
  •     marign:0px; 
  • \r\n\t\t
  • \r\n\t\t
  • ul, li { 
  • \r\n\t\t
  •     list-style: none; 
  • \r\n\t\t
  • \r\n\t\t
  • body { 
  • \r\n\t\t
  •     min-width:1200px; 
  • \r\n\t\t
  •     color: #333; 
  • \r\n\t\t
  •     font-size: 14px; 
  • \r\n\t\t
  •     font-family:\"Microsoft YaHei\"
  • \r\n\t\t
  •     text-align: center; 
  • \r\n\t\t
  •     background-color:#ededed; 
  • \r\n\t\t
  • \r\n\t\t
  • a { 
  • \r\n\t\t
  •     color: #333; 
  • \r\n\t\t
  •     text-decoration: none; 
  • \r\n\t\t
  •     outline: none; 
  • \r\n\t\t
  • \r\n\t\t
  • a:hover { 
  • \r\n\t\t
  •     color: #e00; 
  • \r\n\t\t
  • \r\n\t\t
  • #box { 
  • \r\n\t\t
  •     width: 660px; 
  • \r\n\t\t
  •     margin: 0 auto; 
  • \r\n\t\t
  • \r\n\t\t
  • #box li { 
  • \r\n\t\t
  •     width:180px; 
  • \r\n\t\t
  •     height:300px; 
  • \r\n\t\t
  •     float:left; 
  • \r\n\t\t
  •     margin-left:10px; 
  • \r\n\t\t
  •     margin-right:10px; 
  • \r\n\t\t
  •     background-color:#fff; 
  • \r\n\t\t
  •     padding:10px; 
  • \r\n\t\t
  •     line-height:30px; 
  • \r\n\t\t
  •     margin-bottom:20px; 
  • \r\n\t\t
  • \r\n\t\t
  • #box li .pic a { 
  • \r\n\t\t
  •     height:235px; 
  • \r\n\t\t
  •     overflow:hidden; 
  • \r\n\t\t
  •     display:block; 
  • \r\n\t\t
  • \r\n\t\t
  • #box li img { 
  • \r\n\t\t
  •     width: 100%; 
  • \r\n\t\t
  •     max-width:100%; 
  • \r\n\t\t
  • \r\n\t\t
  •  
  • \r\n\t\t
  •  
  • \r\n\t\t
  •  
  • \r\n\t\t
  •  
  • \r\n\t\t
  • \"box\"
  • \r\n\t\t
  •    
  • \r\n\t\t
  •  
  • \r\n\t\t
  •  
  • \r\n\t\t
  •  
  • \r\n\t\r\n\r\n

    三、输出结果

    \r\n

    \"\"

    ", "copyrightHolder": "本站原创" }
    您的位置: 首页 >日志>前端技术>详细内容

    前端技术

    简单的数据接口调用显示

    来源:本站原创 发布时间:2018-05-31 17:43:00 浏览次数: 【字体:

    项目中涉及到外部数据的显示,往往都是通过接口来实现的,下面以简单的列子简要的阐述一下怎么通过前端来实现接口数据的调用:

    一、接口返回数据(json数据)

    1.     "name": "电视剧", 
    2.     "data": [ 
    3.         { 
    4.             "title": "忘忧酒馆", 
    5.             "href": "", 
    6.             "url": "" 
    7.         }, 
    8.         { 
    9.             "title": "九丹", 
    10.             "href": "", 
    11.             "url": "" 
    12.         }, 
    13.         { 
    14.             "title": "上海女子图鉴", 
    15.             "href": "", 
    16.             "url": "" 
    17.         }, 
    18.         { 
    19.             "title": "楼外楼", 
    20.             "href": "", 
    21.             "url": "" 
    22.         }, 
    23.         { 
    24.             "title": "哦!我的皇帝陛下", 
    25.             "href": "", 
    26.             "url": "" 
    27.         } 
    28.     ] 

    二、前端HTML代码

    1.  
    2.  
    3.  
    4. "UTF-8"
    5. 获取数据 
    6. "text/javascript" src="jquery.js"
    7. "text/css"
    8. * { 
    9.     padding:0px; 
    10.     marign:0px; 
    11. ul, li { 
    12.     list-style: none; 
    13. body { 
    14.     min-width:1200px; 
    15.     color: #333; 
    16.     font-size: 14px; 
    17.     font-family:"Microsoft YaHei"
    18.     text-align: center; 
    19.     background-color:#ededed; 
    20. a { 
    21.     color: #333; 
    22.     text-decoration: none; 
    23.     outline: none; 
    24. a:hover { 
    25.     color: #e00; 
    26. #box { 
    27.     width: 660px; 
    28.     margin: 0 auto; 
    29. #box li { 
    30.     width:180px; 
    31.     height:300px; 
    32.     float:left; 
    33.     margin-left:10px; 
    34.     margin-right:10px; 
    35.     background-color:#fff; 
    36.     padding:10px; 
    37.     line-height:30px; 
    38.     margin-bottom:20px; 
    39. #box li .pic a { 
    40.     height:235px; 
    41.     overflow:hidden; 
    42.     display:block; 
    43. #box li img { 
    44.     width: 100%; 
    45.     max-width:100%; 
    46.  
    47.  
    48.  
    49.  
    50. "box"
    51.   
         
      •  
      •  
      •  

      三、输出结果