(前端) Uncaught TypeError: $(…).scrollSpy is not a function解决


$('body').scrollspy({
target: '#nav',
offset: $(window).height() / 2
});
报错:

Uncaught TypeError: $(…).scrollSpy is not a function

 

首先检查自己引入jquery是不是在其他js语句之前。

其次想要使用scrollspy().必须提前 import bootstrap.min.js .

<script type="text/javascript" src="static/js/bootstrap.min.js"></script>

官网:https://getbootstrap.com/docs/4.0/components/scrollspy/

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM