我试图将Google API链接到我的meteor项目,但似乎无法使其加载。医生说要添加
script src="https://apis.google.com/js/client.js?onload=OnLoadCallback"></script>到头部,我们不能直接在流星上做。
我尝试获取脚本的本地副本并将其添加到客户端文件夹,但在加载时仍然得到'gapi is not defined‘。这种方法适用于filepicker.io,但不适用于这一种。
你知道在哪里或者如何加载这个库吗?
发布于 2013-01-27 08:38:12
发现:最好的方法是使用Google RESTful api。你可以在This SO Question上看到一个可用的例子
发布于 2012-10-30 03:50:41
你可以使用Meteor内置的外部服务来进行身份验证,他们有一个专门针对谷歌的服务:http://docs.meteor.com/#meteor_loginwithexternalservice
要加载client API,只需将其包含在应用程序主html文件的<head>部分。
<script src="https://apis.google.com/js/client.js?onload=OnLoadCallback"></script>您可以通过在控制台中运行gapi来确认它是否已正确加载
发布于 2021-12-17 11:56:29
// Create the script tag, set the appropriate attributes
var script = document.createElement('script');
script.src = 'https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap';
script.async = true;
// Attach your callback function to the `window` object
window.initMap = function() {
// JS API is loaded and available
};
// Append the 'script' element to 'head'
document.head.appendChild(script);参见reference。
https://stackoverflow.com/questions/13123881
复制相似问题