有时候,在VUE中我们使用第三方,其中的对象有哪些属性我们是不知道,开发功能也显示不出来。例如VueSocketIO,我想知道其链接状态,但我并不知道通过this.$socket哪个属性可以获得,通过其下方式打印其所有属性:
for(let s in this.$socket){
console.log("this.$socket", JSON.stringify(s));
}
于是,我发现了this.$socket.connected 这个东西,可以获取websocket的链接状态。