我写的代码看看哪里出问题了

我写的代码看看哪里出问题了

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-top1300px;
}
 
.about .container{
    height157px;
    width1200px;
    margin0 auto;
    /* background-color: red; */
}
 
.about-loading{
    width114px;
    height100%;
    margin0 auto;
    backgroundurl(loading.gif) no-repeat center center;
}
 
.about-item-title{
    font-size17px;
    line-height37px;
    }
 
.about-item{
 
    width277px;
    padding35px 0 35px 23px;
}
 
.footer {
    width100%;
    background-color#f3f5f7;
    /* height: 60px; */
    padding28px 0;
}
 
.footer .container{
    height157px;
    width1200px;
    margin0 auto;
}
 
.footer-loading{
    left-200px;
    width114px;
    height100%;
    margin0 auto;
    backgroundurl(loading.gif) no-repeat 0 30px;
}
 
      
 
.about-item-detail .link{
 
    display: inline-block;
     
    font-size13px;
     
    line-height25px;
     
    margin-right20px;
     
    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">&copy; 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不生效 是什么原因。。 总体问题好多 老师我实在不知道从哪里找问题 从哪里下手 能不能说一下如何找问题的思路 还有问题 出现在哪里了

正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

4回答
好帮手慕言 2020-07-01 09:52:59

同学你好,同学写的代码是可以的,不算是繁琐,同学可以先把整体的思路都掌握了,如果想要再简化的话,可以自己动手写一写。祝学习愉快~

好帮手慕言 2020-06-30 19:02:49

同学你好,可能是老师在粘贴代码出现了问题,如果没有报错的话,同学可以根据老师给出的后面的几点来修改。

祝学习愉快~

  • 提问者 陈立天 #1
    我写的buildfooterHtml buildAboutHtml aboutshow footershow 这几个函数是不是重复了 ,优化的话是不是可以提取出来 然后不同的部分可以用函数回调来写入?
    2020-06-30 20:14:24
提问者 陈立天 2020-06-30 16:50:08

http://img1.sycdn.imooc.com//climg/5efafcb309fc09b307060226.jpg

控制台啥也没有报错我这里显示

  • 提问者 陈立天 #1
    发现那个报错的老师修改的内容源代码没有这几个多出来的字母 可能复制粘贴的时候不小心按到的把
    2020-06-30 16:51:59
好帮手慕言 2020-06-30 16:32:41

同学你好,关于同学的疑问,解答如下:

首先js.js文件中有问题,控制台报错如下:

http://img1.sycdn.imooc.com//climg/5efaf59b09489edf06740205.jpg


报错的行数可能会不准确,但是也八九不离十了,

报错信息提示代码中有意外的标识符,原因是代码中多了一个add,去掉即可

http://img1.sycdn.imooc.com//climg/5efaf5db09b2b40910590236.jpg

修改之后还有报错,是因为代码中多了一个a,去掉即可,如下:

http://img1.sycdn.imooc.com//climg/5efaf609097ce55608310224.jpg

1、fl没有生效,以谷歌为例,可以按F12逐步排查,fl没有生效,是因为代码中少了一个引号,如下:

http://img1.sycdn.imooc.com//climg/5efaf6cc0928d8f105210410.jpg

建议:添加引号,如下:

http://img1.sycdn.imooc.com//climg/5efaf72d09a8abd807730188.jpg

2、这边测试,定时器是生效的,会先显示加载图标,再显示内容,如下:

http://img1.sycdn.imooc.com//climg/5efaf75509ab5e0805290302.jpg

3、页脚的内容没有出现:可以先排查下变量html有没有值,

http://img1.sycdn.imooc.com//climg/5efaf7dd09f4fcd306070268.jpg

打印发现是undefined,那么有可能是buildfooterHtml方法有些问题,检查发现是没有设置返回值,建议:设置返回值,如下:

http://img1.sycdn.imooc.com//climg/5efaf84109a672d103620295.jpg

修改后的效果:

http://img1.sycdn.imooc.com//climg/5efaf8590901664112200356.jpg

遇到问题不要着急,可以多使用console.log()打印,在控制台查看输出结果,慢慢排查

如果我的回答帮到了你,欢迎采纳,祝学习愉快~

问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
2.组件化网页开发
  • 参与学习           人
  • 提交作业       1121    份
  • 解答问题       14456    个

本阶段在运用JS实现动态网页开发的基础上,带你深入理解企业开发核心思想,完成一个企业级网页的开发,体验前端工程师的成就感。

了解课程
请稍等 ...
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师
插入代码