2015-11-04 94 views
5

我越來越ReferenceError: _ is not definedangular-google-maps的ReferenceError:在使用角谷歌,地圖

我真的不明白,爲什麼我得到這個錯誤,因爲我做的到底是什麼_沒有定義寫在網站上。

我也搜索了類似的問題,但他們沒有幫助。

bundle.js

$ = window.$ = window.jQuery = require('./lib/jquery'); 
require('./lib/angular-simple-logger.js'); 
require('./lib/angular-google-maps.js'); 
require('./lib/lodash.js'); 

我importind bundle.jsindex.html。我也嘗試使用ngLodash,但沒有結果。

app.js

var app = angular.module('app', [ 
    'ngLodash', 
    'nemLogging', 
    'uiGmapgoogle-maps' 
]); 

app.config(function(uiGmapGoogleMapApiProvider) { 
    uiGmapGoogleMapApiProvider.configure({ 
     key: '{myKey}', 
     v: '3.20', 
     libraries: 'places' // I don't need the whole map, only the places 
    }); 
}); 

而且我啓用從GoogleMaps ApiGoogle Developer Console

是否有人有這個庫中的一些經驗,可以給我一個提示?

回答

5

您需要添加_ underscore庫作爲依賴項。 npm install underscore,或添加到您的bower配置中,或者用於依賴管理的任何內容。

<script src="bower_components/underscore/underscore-min.js"></script> 
+0

我面臨同樣的問題。我甚至使用maven將下劃線添加爲依賴項,但仍然出現相同的錯誤。任何人都可以請幫我嗎? – Sategroup