我正在尝试创建 anchor 链接滚动以及使用 Bootstrap 显示的工具提示
$(window).scroll(function(){
if ($(window).scrollTop() >= 100) {
$('#header').addClass('fixed');
}
else {
$('#header').removeClass('fixed').fadeOut("slow", 100);
}
$('[data-toggle="tooltip"]').tooltip();
});
$(function() {
$('a.page-scroll').bind('click', function(event) {
var $anchor = $(this);
$('html, body').stop().animate({
scrollTop: $($anchor.attr('href')).offset().top
}, 1500, 'easeInOutExpo');
event.preventDefault();
});
});
$(function() {
$('a.scroll').bind('click', function(event) {
var $anchor = $(this);
$('html, body').stop().animate({
scrollTop: $($anchor.attr('href')).offset().top
}, 1500, 'easeInOutExpo');
event.preventDefault();
});
});
但我在控制台中收到此错误 TypeError: m.easing[this.easing] 不是函数
最佳答案
根据fadeOut文档中,第一个参数应该是动画的持续时间,第二个参数应该是回调。这些持续时间可以以毫秒为单位(正如您在第二个参数中输入的那样),也可以是别名为时间范围的字符串。
基本上,您需要通过以下方式之一更改您的fadeOut
代码:
$('#header').removeClass('fixed').fadeOut("slow");
// OR
$('#header').removeClass('fixed').fadeOut(100);
您还使用 easeInOutExpo
进行缓动。 JQuery 没有与这种缓动捆绑在一起。参见 this页面上写着:
The only easing implementations in the jQuery library are the default, called swing, and one that progresses at a constant pace, called linear. More easing functions are available with the use of plug-ins, most notably the jQuery UI suite.
要使用该缓动,您需要确保包含 jQuery UI作为页面上的外部库。
您还需要 jQuery UI 才能使用 tooltip
方法。
关于javascript - TypeError : m. easing[this.easing] is not a function 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34042314/