課程
/前端開發(fā)
/React.JS
/使用React構(gòu)建一款音樂播放器
我這邊報錯react2.default.createClass is not a function ?目前還不知道怎么解決 ?有遇到過這個問題的同學(xué)么
2017-09-30
源自:使用React構(gòu)建一款音樂播放器 3-6
正在回答
使用es6的語法替代,比如
class?Root?extends?React.Component?{ ??constructor(props)?{ ????super(props); ??} ??componentDidMount()?{ ????let?which?=?Math.floor(Math.random()?*?music.length); ????$('#player').jPlayer({ ??????ready:?function()?{ ????????$(this).jPlayer('setMedia',?{ ??????????mp3:?music[which].url ????????}).jPlayer('play'); ??????}, ??????supplied:?'mp3', ??????wmode:?'window' ????}); ????$('#music-name').text(music[which].name); ??} ??componentWillUnmount()?{ ??} ??render()?{ ????return?( ??????<div> ????????<Header?/> ????????<div?id="player"></div> ????????<div?id="music-name"></div> ????????<Player?/> ??????</div>? ????); ??} }
你安裝是哪個版本的react,如果是最新版16.0的話,createClass已經(jīng)被廢除了,可以使用es6的class替代。
或者你使用和老師相同版本的react就可以了
wsl哈哈
tongwandou 回復(fù) wsl哈哈
慕前端8333036 回復(fù) tongwandou
舉報
從零開始使用React構(gòu)建一款音樂播放器
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2017-10-06
使用es6的語法替代,比如
2017-10-02
你安裝是哪個版本的react,如果是最新版16.0的話,createClass已經(jīng)被廢除了,可以使用es6的class替代。
或者你使用和老師相同版本的react就可以了