Twitter bootstrap 脱咖啡因和咖啡化相互作用
当我将Twitter bootstrap 脱咖啡因和咖啡化相互作用,twitter-bootstrap,bower,browserify,Twitter Bootstrap,Bower,Browserify,当我将debowerify与coffeify一起使用时,出现了bootstrap找不到jquery的问题(浏览器错误): 其中我的source.coffee文件是: $ = jQuery = require ('jquery') require('bootstrap') bootstrap_enabled = (typeof $().modal == 'function') console.log "bootstrap_enabled" console.log bootstrap_enabled
debowerify
与coffeify
一起使用时,出现了bootstrap
找不到jquery的问题(浏览器错误):
其中我的source.coffee
文件是:
$ = jQuery = require ('jquery')
require('bootstrap')
bootstrap_enabled = (typeof $().modal == 'function')
console.log "bootstrap_enabled"
console.log bootstrap_enabled
package.json:
{
"name": "bootstrap_test",
"version": "0.0.1",
"private": true,
"scripts": {
"main": "browserify source.coffee -t coffeeify -t debowerify > main.js --debug"
},
"bootstrap": {
"depends": [
"jquery:$"
]
},
"dependencies": {},
"devDependencies": {
"browserify": "^6.0.2",
"coffeeify": "^0.7.0",
"debowerify": "^0.8.2"
}
}
jquery
和bootstrap
通过bower
安装
但是当我只使用debowerify
而不使用coffeify
时,引导程序加载正常:
$ = jQuery = require ('jquery');
require('bootstrap');
browserify source.js -t debowerify > main.js --debug
所以问题在于
debowerify
和coffeify
的交互作用。如何解决这个问题?解决方案是在添加窗口中添加。在jQuery=
之前:
$ = window.jQuery = require ('jquery')
require('bootstrap')
bootstrap_enabled = (typeof $().modal == 'function')
console.log "bootstrap_enabled"
console.log bootstrap_enabled
现在一切正常
$ = window.jQuery = require ('jquery')
require('bootstrap')
bootstrap_enabled = (typeof $().modal == 'function')
console.log "bootstrap_enabled"
console.log bootstrap_enabled