我在这里遵循简单的教程:https://github.com/JonKernPA/gmaps
我一直收到错误:
couldn't find file 'underscore'
(/app/assets/javascripts/application.js:16)
突出显示以下行:
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
我试着遵循中发布的建议Gmaps未在rails 4+gmaps4rails 2.0.3 中定义
并且我得到了相同的错误,带有突出显示的同一行的错误。当我试图删除线路
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
从application.html.erb,我得到错误"Gmaps not found"
感谢任何帮助,谢谢。Github链接:https://github.com/chiefkikio/circus/
找到了一个解决方案。必须安装gem"underline-rails",然后将其捆绑并重新启动rails服务器。
不是一个教程项目,但我使用gem 'underscore-rails'
(cfhttps://rubygems.org/gems/underscore-rails)以满足gmaps4rails的依赖性。
缩小版的Undercore在文件末尾有这样一行:
//#sourceMappingURL=undercore-min.map
Chrome的开发工具在遇到这条线时会尝试下载undercore-min.map。除非打开开发人员工具,否则用户不会看到此错误。
如果你想消除这个错误,可以在你的项目中添加undercore-min.map(https://github.com/jashkenas/underscore/blob/master/underscore-min.map)或者从undercore.min.js 中删除该行
我也遇到了这个问题,这就是我的原因:我的application.js中所需文件的顺序错误。我要求gmaps之前的CCD_ 2。由于我没有等到controller_name.js文件中的页面加载,所以它是先加载的,试图在定义Gmaps之前使用Gmaps。。我以为这可能会有帮助,但是。。我遇到了另外几个"..未定义"的问题。经过小规模的研究,以下是解决方案:将整个自定义js封装在window.load事件的回调中。我用它和这行:
google.maps.event.addDomListener(window, "load", callback)
希望这将有助于