use worker without js file

  var blob = new Blob(['onmessage=function(e){postMessage(e.data);}']);

    debugger;

    // Obtain a blob URL reference to our worker 'file'.

    var blobURL = window.URL.createObjectURL(blob);



    // create a Worker

    var worker = new Worker(blobURL);

    worker.onmessage = function (e) {

        console.log(e.data);

    };

    worker.postMessage("Send some Data");

  

你可能感兴趣的:(worker)