bootstrap+jquery項目引入檔案報錯的解決方案,bootstrapjquery

來源:互聯網
上載者:User

bootstrap+jquery項目引入檔案報錯的解決方案,bootstrapjquery

做一個項目的時候 ,控制台總是會出現各種bug,其實不用慌張,終結起來也就幾種類型的錯誤,在開發中每次遇到錯誤都善於總結,下次在看到就會胸有成竹知道是什麼情況了,以下是在開發過程中總結的一些錯誤以及錯誤的解決方案。

報錯一:Uncaught ReferenceError: $ is not defined

Uncaught ReferenceError: $ is not definedUncaught ReferenceError: jQuery is not defined

 

錯誤原因:檔案載入的順序不對,jQuery檔案的順序要在前面

 

方法:把jQuery檔案寫在所有script檔案前面

 

報錯二:jsp頁面相對路徑和絕對路徑的問題:

正常路徑:html裡面的../../,改成jsp頁面就找不到路徑了,這個時候成了這個鬼樣子

 

這時候,只需要在檔案裡面加入這段代碼:

 

解決辦法:在<html>和<head>之間插入以下代碼

<% String path = request.getRequestURI(); String basePath = request.getScheme() + "://"   + request.getServerName() + ":" + request.getServerPort()   + path;%><base href="<%=basePath%>" rel="external nofollow" >

報錯三:Uncaught TypeError: $(...).tooltip is not a function

Uncaught TypeError: $(...).tooltip is not a function at HTMLDocument.<anonymous> (app.js:42) at l (jquery.min.js:4) at Object.fireWith [as resolveWith] (jquery.min.js:4) at Function.ready (jquery.min.js:4) at HTMLDocument.S (jquery.min.js:4)

 

原因:包括兩個不同版本的jQuery UI。這可能會導致衝突。嘗試刪除

<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>

解決辦法:

編輯:

<script>jQuery( document ).ready(function( $ ) { $('.hasTooltip').tooltip();});</script>

像這樣使用它,解決了我的問題!

報錯四:Uncaught TypeError: $(...).sortable is not a function

Uncaught TypeError: $(...).sortable is not a function at HTMLDocument.<anonymous> (dashboard.js:12) at l (VM552 jquery.min.js:4) at Object.fireWith [as resolveWith] (VM552 jquery.min.js:4) at Function.ready (VM552 jquery.min.js:4) at HTMLDocument.S (VM552 jquery.min.js:4)

報錯五:bootstrap.min.js:7 Uncaught Error: Bootstrap requires jQuery

bootstrap.min.js:7 Uncaught Error: Bootstrap requires jQuery at bootstrap.min.js:7

 

解決方案:解決方案:將jquery.min.js放在bootstrap.min.js檔案之前引用,bootstrap.min.css檔案在整兩個檔案前後引用都無妨(測試多次)。

總結

以上所述是小編給大家介紹的boostrap+jquery項目引入檔案報錯的解決方案,希望對大家有所協助,如果大家有任何疑問請給我留言,小編會及時回複大家的。在此也非常感謝大家對幫客之家網站的支援!

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.