簡體   English   中英

$.fn 不是對象

[英]$.fn is not an object

我正在嘗試將 scrollspy 與 bootstrap 結合使用,但遇到了一些錯誤。 錯誤控制台不斷返回: TypeError: 'undefined' is not an object (evaluating '$.fn') ,在 bootstrap-scrollspy.js 的第 124 行,這是這一行

var old = $.fn.scrollspy

,這是在 ScrollSpy 插件定義下。 我正在使用直接取自這個 jsFiddle的代碼

有誰知道為什么會這樣?

我會仔細檢查兩件事:

  1. 在頁面上包含 Bootstrap 之前,請確保包含 jQuery。
  2. 確保沒有其他庫(例如原型)覆蓋$變量。

在您的腳本行中,我假設您已經從 jQuery 包含中刪除了“slim”。 但是您是否刪除了“完整性”校驗和? 如果不是,則完整性檢查失敗,並且 jQuery 未加載..(我剛剛遇到了同樣的問題)。

例如這個:

<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>

應該

<script src="https://code.jquery.com/jquery-3.3.1.min.js" crossorigin="anonymous"></script>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM