twitter-bootstrap 错误:未捕获的类型错误:无法读取未定义的 bootstrap-popover.js 的属性“构造函数”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14121509/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error: Uncaught TypeError: Cannot read property 'Constructor' of undefined bootstrap-popover.js
提问by wiz
I'd like to use twitter bootstrap manually, on my rails project.
But I've got this error, and some functions of bootstrap don't work.
我想在我的 rails 项目中手动使用 twitter bootstrap。
但是我遇到了这个错误,并且引导程序的某些功能不起作用。
If you help me, I appreciate it. Thank you.
如果你帮助我,我很感激。谢谢你。
Errors on Console
控制台上的错误
Uncaught TypeError: Cannot read property 'Constructor' of undefined bootstrap-popover.js:38
(anonymous function) bootstrap-popover.js:38
(anonymous function) bootstrap-popover.js:115
未捕获的类型错误:无法读取未定义的 bootstrap-popover.js:38
(匿名函数)bootstrap-popover.js:38
(匿名函数)bootstrap-popover.js:115 的属性“构造函数”
app/view/app/index.html.erb
应用程序/视图/应用程序/index.html.erb
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<%= stylesheet_link_tag "bootstrap" %>
<%= stylesheet_link_tag "bootstrap-responsive" %>
<%= javascript_include_tag "jquery" %>
<%= javascript_include_tag "bootstrap" %>
<%= javascript_include_tag "bootstrap-transition" %>
<%= javascript_include_tag "bootstrap-alert" %>
<%= javascript_include_tag "bootstrap-modal" %>
<%= javascript_include_tag "bootstrap-dropdown" %>
<%= javascript_include_tag "bootstrap-scrollspy" %>
<%= javascript_include_tag "bootstrap-tab" %>
<%= javascript_include_tag "bootstrap-tooltip" %>
<%= javascript_include_tag "bootstrap-popover" %>
<%= javascript_include_tag "bootstrap-button" %>
<%= javascript_include_tag "bootstrap-collapse" %>
<%= javascript_include_tag "bootstrap-carousel" %>
<%= javascript_include_tag "bootstrap-typeahead" %>
<!-- as example, which doesn't work, somehow -->
<i class="icon-search icon-home"></i>
I believe everything necessary js and css files are in
我相信所有必要的 js 和 css 文件都在
- ./app/assets/images
- ./app/assets/javascripts
- ./app/assets/stylesheets
- ./应用程序/资产/图像
- ./app/assets/javascripts
- ./app/assets/stylesheets
回答by R Milushev
If you would like to add asset files ( like .js, .cssor images ) in Rails >3 , you should use manifest files : application.js , application.css . After you copy sources in their directories , you should make declarations like this :
如果您想在 Rails >3 中添加资产文件(例如.js,.css或图像),您应该使用清单文件:application.js、application.css。在它们的目录中复制源代码后,您应该进行如下声明:
application.js :
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require bootstrap-responcive
//= require tree .
and in application.css:
在 application.css 中:
*= require_self
*= require bootstrap
*= require_tree .
It makes useless including `<%= javascript_include_tag %> in your views .
它使在您的视图中包含 `<%= javascript_include_tag %> 变得无用。

