現(xiàn)在有三個(gè)函數(shù),都在componentDidMount()生命周期中componentDidMount() {這里一直監(jiān)聽 _self.clientScript.subscribe('/topic/situation-transmit',function (data) { var returnData = eval('(' + data.body + ')'); var date = new Date(); var showTime = date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds(); console.log(showTime + ' = 接收到的數(shù)據(jù) = ') console.log(returnData.data); _self.setState({ quantity: returnData.data['basicMessage'] })})開始發(fā)第一個(gè)消息_self.clientScript.send( '/topic/graduation-receive', {}, JSON.stringify({ topic: '/topic/situation-transmit', interval: 1, screenType: 'situation' }));這是第二個(gè)函數(shù),我希望在發(fā)送第一個(gè)消息后,監(jiān)聽到返回的數(shù)據(jù),再發(fā)第二個(gè)消息,應(yīng)該怎么實(shí)現(xiàn)?,不想放到監(jiān)聽里面,因?yàn)楸O(jiān)聽會(huì)一直執(zhí)行下面這個(gè)函數(shù)_self.clientScript.send( '/topic/graduation-receive', {}, JSON.stringify({ topic: '/topic/situation-transmit', interval: 1, screenType: 'situation' }));}
在執(zhí)行異步函數(shù)時(shí),先執(zhí)行一個(gè)函數(shù),經(jīng)過一個(gè)異步函數(shù)后,再讓另外一個(gè)函數(shù)執(zhí)行怎么辦?
九州編程
2019-03-07 14:15:21