Angular 4 Embedding SoundCloud Error: Failed to execute 'createPattern' on 'CanvasRenderingContext2D': The canvas width is 0
Angular 4 Embedding SoundCloud Error: Failed to execute 'createPattern' on 'CanvasRenderingContext2D': The canvas width is 0
我试图将 soundcloud iframe 嵌入到我的 angular 4 组件中,但我明白了
错误代码:
Failed to execute 'createPattern' on 'CanvasRenderingContext2D': The canvas width is 0.
我使用的 iframe 代码是:
<iframe width="100%" height="166" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/324479935&color=%23ff5500&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&show_teaser=true"></iframe>
我在 NextJS (React SSR) 应用程序中看到了同样的错误 运行。能够通过确保仅呈现 iframe client-side 来防止它。不是 Angular 但希望相关。
const SoundcloudEmbed = ({embedUrl}) => {
return typeof window === 'undefined' ? null : (
<iframe
width="100%"
height="20"
frameBorder="no"
src={embedUrl}
/>
);
}
我试图将 soundcloud iframe 嵌入到我的 angular 4 组件中,但我明白了 错误代码:
Failed to execute 'createPattern' on 'CanvasRenderingContext2D': The canvas width is 0.
我使用的 iframe 代码是:
<iframe width="100%" height="166" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/324479935&color=%23ff5500&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&show_teaser=true"></iframe>
我在 NextJS (React SSR) 应用程序中看到了同样的错误 运行。能够通过确保仅呈现 iframe client-side 来防止它。不是 Angular 但希望相关。
const SoundcloudEmbed = ({embedUrl}) => {
return typeof window === 'undefined' ? null : (
<iframe
width="100%"
height="20"
frameBorder="no"
src={embedUrl}
/>
);
}