我很难让我的JS在这个非常简单的Foundation / jQuery网站上工作。没什么特别的,只是一个很好的老式HTML页面。在早午餐方面,一切都在编译,文件正在生成。问题是javascript没有在浏览器中运行。没有错误消息 - 只是没有执行(我认为)。看下面,你会看到console.log()
,但它没有在网络检查器中返回任何内容
{
"name": "your-app",
"description": "Description",
"author": "Your Name",
"version": "0.0.1",
"repository": {
"type": "git",
"url": ""
},
"scripts": {
"start": "brunch watch --server"
},
"dependencies": {
"autoprefixer": "^5.2.0",
"babel-brunch": "^5.1.2",
"browser-sync-brunch": "0.0.9",
"brunch": "^2.4.2",
"css-brunch": "^1.7.0",
"foundation-sites": "^6.2.0",
"javascript-brunch": "^1.7.1",
"jquery": "^1.12.1",
"motion-ui": "^1.2.2",
"postcss-brunch": "^0.5.0",
"sass-brunch": "^1.8.11",
"scut": "^1.4.0"
}
}
exports.config =
npm:
enabled: true
globals:
$: 'jquery'
jQuery: 'jquery'
Foundation: 'foundation-sites'
files:
javascripts:
joinTo:
'js/app.js': /^app/
'js/vendor.js': /^node_modules/
stylesheets:
joinTo: 'css/app.css'
plugins:
sass:
options:
includePaths: [
'node_modules/foundation-sites/scss'
'node_modules/motion-ui/src'
'node_modules/scut/dist'
]
postcss:
processors: [
require('autoprefixer')({browsers: ['last 2 versions', 'ie >= 9']})
]
$(document).foundation();
console.log("it works");
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Hi</title>
<link rel="stylesheet" href="css/app.css">
</head>
<body>
hi
<script src="/js/vendor.js"></script>
<script src="/js/app.js"></script>
</body>
</html>