所以我正在创建一个网络工作者:
var arrayit = function(obj) {
return Array.prototype.slice.call(obj);
};
work = arrayit(images);
console.log(work);
//work = images.push.apply( images, array );
// Method : "load+scroll"
var worker = new Worker('jail_worker.js');
worker.postMessage(work)
worker.onmessage = function(event) {
console.log("Worker said:" + event.data);
};
这是图像:
$.jail.initialStack = this;
// Store the selector into 'triggerEl' data for the images selected
this.data('triggerEl', (options.selector) ? $(options.selector) : $window);
var images = this;
我认为我的问题与此有关:
http://dev.w3.org/html5/spec/Overview.html#safe-passing-of-structured-data
我怎样才能解决这个问题?如您所见,我尝试将主机对象切片成一个真正的数组,但这没有用。
这是我正在破解的文件的链接:
https://github.com/jtmkrueger/JAIL
更新 - - - - - - - - - - - - - - - - - - - - - - - - - -
根据@davin 接受的答案,这是我必须做的:
var arrayit = function(obj) {
return Array.prototype.slice.call(obj);
};
imgArray = arrayit(images);
work = _.map(images, function(i){ return i.attributes[0].ownerElement.outerHTML; });
var worker = new Worker('jail_worker.js');
worker.postMessage(work)
worker.onmessage = function(event) {
console.log("Worker said:" + event.data);
};
注意:我使用 underscore.js 来确保兼容性。