老师帮我看下代码 报错了 不知道怎么解决
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link rel="stylesheet" href="./css/base.css"> <link rel="stylesheet" href="./font/iconfont.css"> <title>dropDown</title> <style> .dropdown { position: relative; /* margin: 150px; */ } .dropdown-toggle { position: relative; z-index: 2; } /* 下拉箭头 */ .dropdown-arrow { display: inline-block; /* text-align: center; */ vertical-align: text-top; } .dropdown-layer { display: none; overflow: hidden; position: absolute; z-index: 1; } .dropdown-left { left: 0; right: auto; } .dropdown-right { right: 0; left: auto; } /* menu dropdown */ .menu .dropdown-toggle { display: block; height: 100%; padding: 0 16px 0 12px; border-left: 1px solid #f3f5f7; border-right: 1px solid #f3f5f7; } .menu .dropdown-arrow { margin-left: 5px; } .menu .dropdown-layer { /* top: 44px; */ top: 100%; border: 1px solid #cdd0d4; /* border-top: none; */ background-color: #fff; } .menu-item { display: block; height: 30px; padding: 0 12px; line-height: 30px; white-space: nowrap; color: #4d555d; } .menu-item:hover { background-color: #f3f5f7; } /* css hover 实现显示隐藏 */ .menu-active .dropdown-toggle { background-color: #fff; border-color: #cdd0d4; } /* 下拉箭头效果 */ [class *= "-active"] .dropdown-arrow { -o-transform: rotate(180deg); -ms-transform: rotate(180deg); -moz-transform: rotate(180deg); -webkit-transform: rotate(180deg); transform: rotate(180deg); } .transition { -o-transition: all 0.5s; -ms-transition: all 0.5s; -moz-transition: all 0.5s; -webkit-transition: all 0.5s; transition: all 0.3s; } /* .menu-active .dropdown-layer { display: block; } */ /* 显示隐藏效果 */ .fadeOut { visibility: hidden !important; opacity: 0 !important; } .slideUpDownCollapse { height: 0 !important; padding-top: 0 !important; padding-bottom: 0 !important; } .slideLeftRightCollapse { width: 0 !important; padding-left: 0 !important; padding-right: 0 !important; } </style> </head> <body> <div class="menu dropdown fl" data-active="menu"> <a href="" class="dropdown-toggle">我的慕淘<i class="iconfont dropdown-arrow transition"></i></a> <ul class="dropdown-layer dropdown-left"> <li><a href="###" class="menu-item">已买到宝贝</a></li> <li><a href="###" class="menu-item">我的足迹</a></li> </ul> </div> <script src="./js/jquery.js"></script> <script src="./js/transition.js"></script> <script src="./js/showHide.js"></script> <script src="./js/dropDown.js"></script> <script> $('.dropdown').dropdown({ css3: true, js: true, animation: 'slideUpDown', active: 'menu' }); </script> </body> </html>
(function ($) { 'use strict'; // Constructor function Dropdown(elem, options) { this.$elem = $(elem), this.$layer = this.$elem.find('.dropdown-layer'), this.activeClass = options.active + '-active'; this.$layer.showHide(options); this.$elem.hover($.proxy(this.show, this), $.proxy(this.hide, this)); } Dropdown.DEFAULTS = { css3: false, js: false, animation: 'fade', active: 'dropdown' }; Dropdown.prototype.show = function () { // console.log(this); this.$elem.addClass(this.activeClass); this.$layer.showHide('show'); }; Dropdown.prototype.hide = function () { this.$elem.removeClass(this.activeClass); this.$layer.showHide('hide'); }; var dropdown = new Dropdown(); dropdown.show(); dropdown.hide(); $.fn.extend({ dropdown: function (option) { return this.each(function () { var options = $.extend({}, Dropdown.DEFAULTS, option); new Dropdown(this, options); }); } }); })(jQuery);
10
收起
正在回答
2回答
同学你好,针对你截图的报错信息,在dropdown.js文件里面,把下列代码去掉就可以了。
如果我的回答帮助到了你,欢迎采纳,祝学习愉快~
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星