现在有三个函数,都在componentDidMount()生命周期中componentDidMount() {这里一直监听 _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 + ' = 接收到的数据 = ') console.log(returnData.data); _self.setState({ quantity: returnData.data['basicMessage'] })})开始发第一个消息_self.clientScript.send( '/topic/graduation-receive', {}, JSON.stringify({ topic: '/topic/situation-transmit', interval: 1, screenType: 'situation' }));这是第二个函数,我希望在发送第一个消息后,监听到返回的数据,再发第二个消息,应该怎么实现?,不想放到监听里面,因为监听会一直执行下面这个函数_self.clientScript.send( '/topic/graduation-receive', {}, JSON.stringify({ topic: '/topic/situation-transmit', interval: 1, screenType: 'situation' }));}
添加回答
举报
0/150
提交
取消
