我有這些依賴關係的bower.json:涼亭:jQuery是聲明的依賴,但不知何故失蹤
"dependencies": {
"bootstrap": "~3.0.2",
"jquery": "~2.0.3",
"modernizr": "~2.7.0"
}
生產文件,然後使用咕嚕建。
Bower和Grunt配置使用yeoman和generator-webapp(之後我包括bootstrap3和更新的jquery和modernizr)。
頁顯示了這個錯誤:「未捕獲錯誤:引導需要jQuery的」
出了什麼問題?
有沒有辦法確保在引導之前加載jquery?我試過改變bower.json中的依賴關係的順序,但它沒有幫助。
難道是在構建過程中沒有包含jquery嗎?我怎麼會知道? (我是自耕農,涼亭和咕嚕小白)
這是我的index.html:
<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="CH"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="CH"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="CH"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="CH"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>gabriel</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<!-- build:css(.tmp) styles/main.css -->
<!-- bower:css -->
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css" />
<!-- endbower -->
<!-- endbuild -->
<!-- build:js scripts/vendor/modernizr.js -->
<script src="bower_components/modernizr/modernizr.js"></script>
<!-- endbuild -->
</head>
<body>
<!--[if lt IE 10]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<div class="hero-unit">
<h1>'Allo, 'Allo!</h1>
<p>You now have</p>
<ul>
<li>HTML5 Boilerplate</li>
<li>Modernizr</li>
</ul>
</div>
<!-- build:js scripts/vendor.js -->
<!-- bower:js -->
<script src="bower_components/bootstrap/dist/js/bootstrap.js"></script>
<!-- endbower -->
<!-- endbuild -->
<!-- Google Analytics: change UA-XXXXX-X to be your site's ID. -->
<script>
(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=
function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;
e=o.createElement(i);r=o.getElementsByTagName(i)[0];
e.src='//www.google-analytics.com/analytics.js';
r.parentNode.insertBefore(e,r)}(window,document,'script','ga'));
ga('create','UA-XXXXX-X');ga('send','pageview');
</script>
<!-- build:js scripts/main.js -->
<script src="scripts/main.js"></script>
<!-- endbuild -->
</body>
</html>
腳本加載後,檢查jQuery是否存在。那麼你至少可以把問題縮小到訂單問題。 – Brad
我在「dist」文件夾中找不到jquery的任何痕跡,其中產品代碼由grunt構建插入。它在index.html中的html中也沒有出現。 – Alex
我添加了我的index.html文件。也許這就是應該改變的地方? – Alex