【发布时间】:2019-05-03 19:05:57
【问题描述】:
我正在尝试在 Angular 中设置一种仅在流在线时才显示 Twitch 播放器的方式,因此在 Documentation 中有这个内联 HTML:
<script src= "https://player.twitch.tv/js/embed/v1.js"></script>
<div id="<player div ID>"></div>
<script type="text/javascript">
var options = {
width: <width>,
height: <height>,
channel: "<channel ID>",
video: "<video ID>",
collection: "<collection ID>",
};
var player = new Twitch.Player("<player div ID>", options);
player.setVolume(0.5);
</script>
当然,尽管在 Angular 组件中我们不能使用 标签,而且我认为目前无法在我的组件 TypeScript 中使用 require 或 import 来使用它。
那么我该如何添加这个功能呢?在我可以实际引用该脚本标记后,我明白该怎么做。
【问题讨论】:
-
为什么不将脚本包含在 angular.json 的“脚本”中?
标签: node.js angular typescript twitch