有时,作为一名Web开发人员,我们想共享我们的社交媒体链接,为此,我们必须显示社交媒体按钮,并且amp-addthis专门用于此目的。 amp-addthis组件集成了AddThis浮点数栏和内联共享按钮。
设置:
您必须在标头中导入amp-addthis组件才能使用此标记。
HTML
<script async custom-element="amp-addthis" src=
"https://cdn.ampproject.org/v0/amp-addthis-0.1.js">
</script>
转到此网站https://www.addthis.com/register,然后创建您的自定义窗口小部件,这绝对是免费的。填写详细信息并创建自定义窗口小部件后,您将被定向到包含代码的页面。复制它并将其粘贴到您的程序代码中。
属性:
- data-pub-id:它是所使用的窗口小部件的发布者的发布者ID。
- data-widget-id:它是正在使用的窗口小部件的窗口小部件ID。
- data-widget-type:此属性从浮点数和内联描述小部件的类型。
- data-title:它是一个可选属性,用于设置工具的标题。如果不存在,则会采用文档中存在的那个。
- data-url:它是一个可选属性,用于设置要共享的URL。如果不存在,则会采用文档中存在的那个。
- data-media:它是可选属性,用于定义要共享的媒体的URL。如果不存在,则未定义。
- data-description:它是可选属性,用于设置页面描述。如果不存在,则未定义。
例:
HTML
<!doctype html>
<html amp>
<head>
<meta charset="utf-8">
<script async src=
"https://cdn.ampproject.org/v0.js">
</script>
<script async custom-element="amp-accordion"
src="https://cdn.ampproject.org/v0/amp-accordion-0.1.js">
</script>
<link rel="canonical" href=
"https://amp.dev/documentation/examples/components/amp-addthis/index.html">
<meta name="viewport" content=
"width=device-width,minimum-scale=1,initial-scale=1">
<title>Google AMP amp-addthis</title>
<style amp-boilerplate>
body {
-webkit-animation:-amp-start 8s
steps(1, end) 0s 1 normal both;
-moz-animation:-amp-start 8s
steps(1, end) 0s 1 normal both;
-ms-animation:-amp-start 8s
steps(1, end) 0s 1 normal both;
animation:-amp-start 8s
steps(1, end) 0s 1 normal both;
}
@-webkit-keyframes -amp-start {
from {
visibility:hidden
}
to {
visibility:visible
}
}
@-moz-keyframes -amp-start {
from {
visibility:hidden
}
to {
visibility:visible
}
}
@-ms-keyframes -amp-start {
from {
visibility:hidden
}
to {
visibility:visible
}
}
@-o-keyframes -amp-start {
from {
visibility:hidden
}
to {
visibility:visible
}
}
@keyframes -amp-start {
from {
visibility:hidden
}
to {
visibility:visible
}
}
</style>
<noscript>
<style amp-boilerplate>
body {
-webkit-animation:none;
-moz-animation:none;
-ms-animation:none;
animation:none
}
</style>
</noscript>
<script async custom-element="amp-addthis"
src="https://cdn.ampproject.org/v0/amp-addthis-0.1.js">
</script>
<style amp-custom>
h1 {
color:green;
text-align:center;
}
</style>
</head>
<body>
<h1>
Geeks For Geeks
</h1>
<amp-addthis width="320" height="92"
data-pub-id="ra-5c191331410932ff"
data-widget-id="mv93"
data-widget-type="inline">
</amp-addthis>
</body>
</html>
输出:
相关用法
- Google AMP amp-ad用法及代码示例
- Google AMP amp-accordion用法及代码示例
- Google AMP amp-facebook-like用法及代码示例
- Google AMP amp-carousel用法及代码示例
- Google AMP amp-date-countdown用法及代码示例
- Google AMP amp-brightcove用法及代码示例
- Google AMP amp-bind-recaptcha用法及代码示例
- Google AMP amp-autocomplete用法及代码示例
- Google AMP amp-img用法及代码示例
- Google AMP amp-image-lightbox用法及代码示例
- Google AMP amp-lightbox-gallery用法及代码示例
- Google AMP amp-soundcloud用法及代码示例
- Google AMP amp-mustache用法及代码示例
注:本文由纯净天空筛选整理自aditya_taparia大神的英文原创作品 Google AMP amp-addthis。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。