我正在尝试嵌入soundcloud音轨。我已经将ReactSoundcloud导入到页面中,现在我在返回中使用它后会出现这些错误。我究竟做错了什么? (p.s. url值是用于测试目的的占位符)
我的代码:
position: relative
答案 0 :(得分:0)
我将我的soundcloud组件更改为
class ReactSoundcloud extends React.Component
{
constructor()
{
super();
this.props =
{
width: "100%",
height: "450px",
url: "https://soundcloud.com/icebound/dusty-breaks-at-the-bottom-of-the-random-crates",
autoPlay: false,
hideRelated: false,
showComments: true,
showUser: true,
showReposts: false,
visual: true,
color: "ff5500"
};
}
render() {
const { url, width, height, autoPlay, hideRelated,
showComments, showUser, showReposts, visual, color } = this.props;
var src = visual ?
`https://w.soundcloud.com/player/?url=${url}&auto_play=${autoPlay}&hide_related=${hideRelated}&show_comments=${showComments}&show_user=${showUser}&show_reposts=${showReposts}&visual=${visual}` :
`https://w.soundcloud.com/player/?url=${url}&color=${color}&auto_play=${autoPlay}&hide_related=${hideRelated}&show_comments=${showComments}&show_user=${showUser}&show_reposts=${showReposts}`;
return (
<iframe
width={ width }
height={ visual ? height : "auto" }
scrolling="no"
frameBorder="no"
src={ src } />
);
};
}
module.exports = ReactSoundcloud;
https://github.com/keske/react-soundcloud/blob/master/src/ReactSoundcloud.js
如果您在源中看到有点偏离差异
首次使用静态defaultProps = {给我一个browsefy错误, second frameBorder =&#34; no&#34; in source frameborder =&#34; no&#34;
我没有经过测试,但音乐现在在我的页面上播放! :)
嗯,我不知道为什么会出现警告
&#39;警告:ReactSoundcloud(...):在ReactSoundcloud
中调用super()时,请确保传递组件的构造函数传递的相同道具。&#39 ;