【发布时间】:2019-05-29 16:03:29
【问题描述】:
在需要 AddThis 来共享页面的 Angular 6/7 网站上工作。首先,设置一个简单的 HTML 页面,如下所示:
<html>
<head></head>
<body>
<div>AddThis below</div>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style">
<a class="addthis_button_facebook"></a>
<a class="addthis_button_twitter"></a>
<a class="addthis_button_email"></a>
<a class="addthis_button_linkedin"></a>
<a class="addthis_button_compact"></a>
</div>
<div>AddThis above</div>
<script type="text/javascript" src="http://s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5c2bf6b040727c90" async="async"></script>
</body>
</html>
这可以正常工作并按预期显示按钮。
然后尝试将其移动到 Angular 中。设置一个简单的组件来保存 HTML。尝试将脚本标签放入 index.html。在组件中也试过了。在任何情况下,我都无法让它显示任何东西。
设置 StackBlitz angular-addthis
然后咨询了 AddThis 技术支持。他们表示我可能必须在路由后运行一个方法(addthis.layers.refresh())来刷新......但它永远不会走那么远。什么都没有显示。
在 StackBlitz 中,AddThis 代码是 app.component。测试 HTML 在standalone.html 中。
任何想法表示赞赏。
【问题讨论】: