1.npm 安裝soket.io.js
npm install socket.io-client??
2.封裝socket.io.js
import?io?from?'socket.io-client';
import?{socket_url}?from?'../../../components/config/config'
const?socketBGP?=?io.connect('/bgp_events');
function?tableDataSocket(cb){
??socketBGP.on('bgp_events',?timestamp?=>?{
????cb(null,?timestamp)});
}
export?{tableDataSocket};
3.?tableDataSocket((err,timestamp)=>{
? ? ? ? ? ? ? ?console.log(timestamp)
??????}
????})