this.ws.onmessage = async (msg) => {
console.log('從服務端獲取到了數據')
// 從真正服務端發送過來的原始數據時在msg中的data字段
console.log(msg.data)
// 獲取Blob的值
const text = await (new Response(msg.data)).text()
console.log(text)
const recvData = JSON.parse(msg.data)
const socketType = recvData.socketType
// 判斷回調函數是否存在
if (this.callBackMapping[socketType]) {
const action = recvData.action
if (action === 'getData') {
const realData = JSON.parse(recvData.data)
this.callBackMapping[socketType].call(this, realData)
} else if (action === 'fullScreen') {
this.callBackMapping[socketType].call(this, recvData)
} else if (action === 'themeChange') {
this.callBackMapping[socketType].call(this, recvData)
}
}
}

參考鏈接
https://developer.mozilla.org/zh-CN/docs/Web/API/Blob