我写的代码看看哪里出问题了
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | <!DOCTYPE html> < html lang = "en" > < head > < meta charset = "UTF-8" > < meta name = "viewport" content = "width=device-width, initial-scale=1.0" > < title >自己写的代码</ title > < link rel = "stylesheet" href = "acss.css" > < link rel = "stylesheet" type = "text/css" href = "./css/base.css" > </ head > < body > < div class = "about" id = "about" > < div class = "container" > < div class = "about-loading" ></ div > </ div > </ div > < div class = "footer" id = "footer" > < div class = "container" > < div class = "footer-loading" ></ div > </ div > </ div > < script src = "js/jquery.js" ></ script > < script src = "js/transition.js" ></ script > < script src = "js/showHide.js" ></ script > < script src = "js.js" ></ script > </ body > </ html > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | .about{ /* background-color: red; */ margin-top : 1300px ; } .about .container{ height : 157px ; width : 1200px ; margin : 0 auto ; /* background-color: red; */ } .about-loading{ width : 114px ; height : 100% ; margin : 0 auto ; background : url (loading.gif) no-repeat center center ; } .about-item-title{ font-size : 17px ; line-height : 37px ; } .about-item{ width : 277px ; padding : 35px 0 35px 23px ; } .footer { width : 100% ; background-color : #f3f5f7 ; /* height: 60px; */ padding : 28px 0 ; } .footer .container{ height : 157px ; width : 1200px ; margin : 0 auto ; } .footer-loading{ left : -200px ; width : 114px ; height : 100% ; margin : 0 auto ; background : url (loading.gif) no-repeat 0 30px ; } .about-item-detail .link{ display : inline- block ; font-size : 13px ; line-height : 25px ; margin-right : 20px ; color : #93999f ; } .about-item{ /* background-color: red; */ } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | ( function ($) { 'use strict' ; // lazyLoad var lazyLoad={}; lazyLoad.$win=$(window); lazyLoad.isVisible= function (option){ var $win=lazyLoad.$win; return $win.height()+$win.scrollTop()>option.offsetTop && $win.scrollTop() < option.offsetTop+option.height; } // about var about ={}; about.$about=$( '#about' ); about.options={}; about.$container=about.$about.find( '.container' ); about.options.offsetTop=about.$about.offset().top; about.options.height=about.$about.height(); about.data=[ { title: '消费者保障' , detail:[ '保障范围' , '退货退款流程' , '服务中心' , '更多特色服务' ] }, { title: '新手上路' , detail:[ '新手专区' , '消费警示' , '交易安全' , '24小时在线帮助' , '免费开店' ] }, { title: '付款方式' , detail:[ '快捷支付' , '信用卡' , '余额宝' , '蜜蜂花啊' , '货到付款' ] }, { title: '慕淘特色' , detail:[ '手机慕淘' , '慕淘信' , '大众评审' , 'B格指南' ] } ] about.buildAboutHtml= function (){ var html= '' ; for ( var i=0;i<about.data.length;i++){ html+= '<dl class="about-item fl><dt class="about-item-title">' +about.data[i].title+ '</dt><dd class="about-item-detail">' for ( var j=0;j<about.data[i].detail.length;j++){ html+= '<a herf="###" target="_blank" class="link">' +about.data[i].detail[j]+ '</a>' ; } html+= '</dd>' ; html+= '</dl>' ; } return html; }; about.aboutshow= function (){ var html= '' ; if (lazyLoad.isVisible(about.options)){ html=about.buildAboutHtml(); about.$container.html(html) } }; // footer var footer ={}; footer.$footer=$( '#footer' ); footer.$container=footer.$footer.find( '.container' ); footer.options={}; footer.options.offsetTop=footer.$footer.offset().top; footer.options.height=footer.$footer.height(); footer.data=[ '关于慕淘' , '合作伙伴' , '营销中心' , '廉政举报' , '联系客服' , '开放平台' , '诚征英才' , '联系我们' , '网站地图' , '法律声明' , '知识产权' ]; footer.buildfooterHtml= function (){ var html= '' ; html+= '<p class="footer">' for ( var i=0;i<footer.data.length;i++){ html+= '<a>' +footer.data[i]+ '</a>' ; } html+= '</p><p class="site-right">© 2017 imooc.com All Rights Reserved</p>' } footer.footershow= function (){ var html= '' ; if (lazyLoad.isVisible(footer.options)){ html=footer.buildfooterHtml(); footer.$container.html(html); } }; lazyLoad.$win.on( 'scroll resize' , function (){ clearTimeout(); lazyLoad.lazyLoadTimer=setTimeout( function (){ footer.footershow(); about.aboutshow(); },3000) }) })(jQuery); |
老师我写的代码fl样式无法生效,,css 的class写的一些样式也不能生效 还有写的延时3秒出现的那个也没生效 自动就出现了。。 另外那个footer的为什么显示不出来? about的 fl不生效 是什么原因。。 总体问题好多 老师我实在不知道从哪里找问题 从哪里下手 能不能说一下如何找问题的思路 还有问题 出现在哪里了
25
收起
正在回答 回答被采纳积分+1
4回答
好帮手慕言
2020-06-30 16:32:41
同学你好,关于同学的疑问,解答如下:
首先js.js文件中有问题,控制台报错如下:
报错的行数可能会不准确,但是也八九不离十了,
报错信息提示代码中有意外的标识符,原因是代码中多了一个add,去掉即可
修改之后还有报错,是因为代码中多了一个a,去掉即可,如下:
1、fl没有生效,以谷歌为例,可以按F12逐步排查,fl没有生效,是因为代码中少了一个引号,如下:
建议:添加引号,如下:
2、这边测试,定时器是生效的,会先显示加载图标,再显示内容,如下:
3、页脚的内容没有出现:可以先排查下变量html有没有值,
打印发现是undefined,那么有可能是buildfooterHtml方法有些问题,检查发现是没有设置返回值,建议:设置返回值,如下:
修改后的效果:
遇到问题不要着急,可以多使用console.log()打印,在控制台查看输出结果,慢慢排查
如果我的回答帮到了你,欢迎采纳,祝学习愉快~
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧