词缀不是函数 [英] Affix is not a function

查看:79
本文介绍了词缀不是函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一段时间以来,我一直在尝试使用Bootstrap 4 Alpha在我的Wordpress网站上创建一个粘性侧边栏.我在网上发现了与此问题类似的其他问题,并且大多数建议将代码放入

I've been trying to create a sticky sidebar for a while on my Wordpress site with Bootstrap 4 Alpha. I've found other issues similar to this one online and most suggest putting the code inside of

jQuery(document).ready(function($){
});

我已经尝试过了,但是没有成功.我还尝试过重新安排脚本调用的顺序,但也没有用.

I've tried this but was not successful. I've also tried rearranging the order of how my scripts are being called and that hasn't worked either.

这是我目前拥有的基本Bootstrap侧边栏代码

Here is the basic Bootstrap sidebar code that I currently have

jQuery(document).ready(function($){
$('#sidebar').affix({
      offset: {
        top: 245
      }
});

var $body   = $(document.body);
var navHeight = $('.navbar').outerHeight(true) + 10;

$body.scrollspy({
    target: '#leftCol',
    offset: navHeight
});
});

这是错误消息

未捕获的TypeError:$(...).affix不是函数

Uncaught TypeError: $(...).affix is not a function

有人会偶然知道为什么会发生此问题吗?

Would anyone happen to know why this issue is occurring?

谢谢

推荐答案

该附件已从引导版本4中删除. Bootstrap 4文档说-

Affix is removed from bootstrap version 4. Bootstrap 4 documentation says--

删除了Affix jQuery插件.我们建议使用一个位置:粘稠的polyfill.有关详细信息和特定的polyfill建议,请参见HTML5 Please条目.

Dropped the Affix jQuery plugin. We recommend using a position: sticky polyfill instead. See the HTML5 Please entry for details and specific polyfill recommendations.

如果您使用Affix来应用其他非位置样式,则 polyfills可能不支持您的用例.这种用途的一种选择是 第三方ScrollPos-Styler库.

If you were using Affix to apply additional, non-position styles, the polyfills might not support your use case. One option for such uses is the third-party ScrollPos-Styler library.

现在可以采取补救措施了---

Now comes the remedy for it---

看看它应该可以帮助您实现所需的目标

这篇关于词缀不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆