共享工人teminated刷新页面上(Shared worker is teminated on r

2019-10-22 04:23发布

为什么共享工人死在刷新页面? 它一定是复活了。 我怎样才能解决这个问题?

重装之前

重装(按F5在example.com)后

家长工人

var port = new SharedWorker('/app/worker-5n1261e73b.js').port;
port.onmessage = function(e){
    console.log(e.data);
};
port.start();

工人5n1261e73b.js

onconnect = function(e){
    var port = e.ports[0];
    port.onmessage = function(e){
         console.log(e.data);
    };
    port.start();
    port.postMessage('Connected');
};
文章来源: Shared worker is teminated on reloading page