草庐IT

javascript - 引用错误 : _ is not defined while using angular-google-maps

coder 2025-04-02 原文

我收到 ReferenceError: _ is not defined angular-google-maps

我真的不明白为什么我会收到这个错误,因为我完全按照网站上写的去做。

我也搜索过类似的问题,但没有帮助。

bundle.js

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

我正在将 bundle.js 导入到 index.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
   });
});

我还从 Google Developer Console

启用了 GoogleMaps Api

有人对这个库有一些经验并且可以给我提示吗?

最佳答案

您需要添加 _ underscore库作为依赖项。 npm install underscore,或者添加到你的 bower 配置,或者你用于依赖管理的任何东西。

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

关于javascript - 引用错误 : _ is not defined while using angular-google-maps,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33530717/

有关javascript - 引用错误 : _ is not defined while using angular-google-maps的更多相关文章

随机推荐