vue pako 使用
ws推送的gzip壓縮能減少大量的傳輸數(shù)據(jù),減少傳輸數(shù)據(jù)消耗
但是需要在收到數(shù)據(jù)之后解壓。
解壓就可以用到pako了
下載
npm install pako
function (msg) {
let reader = new FileReader()
reader.readAsBinaryString(msg) // blob
reader.onload = function () {
result = JSON.parse(pako.inflate(reader.result, { to: 'string' }))
// 打印出返回的數(shù)據(jù)
console.log(result)
}
}