在Polymer.js中, Google客户端加载程序用于加载特定的客户端。它与带有JavaScript客户端库的Google API一起使用。
运行以下命令以在你的项目目录中安装polymer_google-client-loaderelement。之后, 你可以在应用程序中使用此元素:
bower install --save GoogleWebComponents/google-apis
文章图片
它将在bower_components文件夹下安装polymer_google-client-loader的所有相关元素。
例:
【Polymer Google客户端加载器】创建一个index.html文件并在其中添加以下代码, 以查看Polymer.js中google-client-loader元素的用法。
<
html>
<
head>
<
script src = "http://www.srcmini.com/bower_components/webcomponentsjs/webcomponents-lite.js">
<
/script>
<
link rel = "import" href = "http://www.srcmini.com/bower_components/google-apis/google-apis.html">
<
/head>
<
body>
<
div id = "loadedmsg">
<
/div>
<
templateid = "googleclient" is = "dom-bind">
<
google-client-loader id = "shortener"name = "urlshortener"version = "v1"on-google-api-load = "loadedShortener">
<
/google-client-loader>
<
google-js-apion-js-api-load = "msgloaded">
<
/google-js-api>
<
google-plusone-apion-api-load = "msgloaded">
<
/google-plusone-api>
<
/template>
<
script>
var googleclient = document.querySelector('#googleclient');
googleclient.loadedShortener= function(event) {var request = event.target.api.url.get ({shortUrl: 'http://goo.gl/fbsS'})request.execute(function(resp) {});
};
googleclient.msgloaded = function(e) {document.querySelector('#loadedmsg').innerHTML +=e.target.localName + ' is loaded' + '<
br>
';
};
<
/script>
<
/body>
<
/html>
推荐阅读
- Polymer Google街景全景
- Polymerjs Google地图
- Polymerjs Google环聊按钮
- Polymer Google Analytics(分析)查询
- Polymerjs gold-phone-input元素
- Polymerjs Google图表
- Polymerjs gold-email-input元素
- Polymerjs事件处理详解
- Polymerjs gold元素