(前端) 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/

 

posted @ 2020-07-07 22:22  Yao靠自己  阅读(1240)  评论(0编辑  收藏  举报