简体   繁体   English

无法通过ember-cli-build.js加载bootstrap js

[英]Can't load bootstrap js via ember-cli-build.js

In my project if I include bootstrap's javascrpt file via 在我的项目中,如果我通过以下方式包含引导程序的javascrpt文件

app.import(app.bowerDirectory + '/bootstrap/dist/js/bootstrap.min.js'); in ember-cli-build.js I get a bunch of js errors. ember-cli-build.js我收到了一堆js错误。

If instead I include it in index.html it works fine. 相反,如果我将它包含在index.html中,则效果很好。 Any idea what could be causing this? 知道是什么原因造成的吗?

Error- 错误-

SyntaxError: export declarations may only appear at top level of a module

I can think of 3 things to try here: 我可以想到以下三点尝试:

Link to the full file. 链接到完整文件。 I had this line in a (pretty old) app that worked fine: app.import(app.bowerDirectory + '/bootstrap/dist/js/bootstrap.js'); 我在运行良好的(相当旧的)应用中使用了这一行:app.import(app.bowerDirectory +'/bootstrap/dist/js/bootstrap.js');

Make sure you app.import is inside of the main module.exports declaration in your ember cli build. 确保app.import在ember cli版本的main module.exports声明中。

You might also try testing it out with a different bower package to see if the problem is bootstrap or your app. 您也可以尝试使用其他Bower软件包对其进行测试,以查看问题是自举还是您的应用。

If all else fails (and even if it succeeds), I highly recommend using ember bootstrap instead. 如果所有其他方法都失败了(即使成功了),我强烈建议改用ember bootstrap。 It will handle the stylesheets for you and provide some Ember friendly ways to implement bootstrap components. 它将为您处理样式表,并提供一些Ember友好方式来实现引导程序组件。 You won't need to do the import anymore. 您不再需要进行导入。 Overall, it's best to avoid mixing libraries that modify the DOM (like plain bootstrap) with ember components. 总体而言,最好避免将修改DOM的库(如普通引导程序)与ember组件混合使用。 http://www.ember-bootstrap.com http://www.ember-bootstrap.com

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM