我使用Vue框架。下面的代码是我的vue文件" xxxx.vue"中的方法之一。我想使用Vue-workers。但它给我带来了错误。
我只是使用此示例代码使vue-workers工作
this.$worker.run(function, args[])
<script>
export default {
mounted() {
this.$worker.run((arg) => {
return `Hello, ${arg}!`
}, ['World'])
.then(result => {
console.log(result)
})
.catch(e => {
console.error(e)
})
}
}
</script>
...
My codes:=================================================================
searchElement(arr, target, obj, spId, typeId) {
console.log("searchElement_this.searchElement", this.searchElement);
var f = this.searchElement;
var _typeId = typeId;
arr.forEach(e => {
if (e.class === target) {
if (spId == e.spMemberId && typeId == e.value) {
e.children = obj;
return;
}
return;
} else {
this.$worker.run(f, [e.children, target, obj, spId, typeId]);
}
return;
});
}
&#13;
Chrome中的开发者工具中只显示两种类型的错误。
Error: Line 5 in blob:http://localhost:8099/896b6d24-5596-49c0-b301-00464dc008fc: Uncaught SyntaxError: Unexpected identifier
Uncaught (in promise) ErrorEvent {isTrusted: true, message: "Uncaught SyntaxError: Unexpected identifier", filename: "blob:http://localhost:8099/896b6d24-5596-49c0-b301-00464dc008fc", lineno: 5, colno: 47, …}
&#13;
ErrorEvent {isTrusted: true, message: "Uncaught SyntaxError: Unexpected identifier", filename: "blob:http://localhost:8099/3740c6f2-3bf1-402f-bb46-f291df4310d7", lineno: 5, colno: 47, …}
bubbles:false
cancelBubble:false
cancelable:true
colno:47
composed:false
currentTarget:Worker {post: ƒ, onmessage: ƒ, onerror: ƒ}
defaultPrevented:false
error:null
eventPhase:0
filename:"blob:http://localhost:8099/3740c6f2-3bf1-402f-bb46-f291df4310d7"
isTrusted:true
lineno:5
message:"Uncaught SyntaxError: Unexpected identifier"
path:[]
returnValue:true
srcElement:Worker {post: ƒ, onmessage: ƒ, onerror: ƒ}
target:Worker {post: ƒ, onmessage: ƒ, onerror: ƒ}
timeStamp: 2669301.5000000596
type:"error"
__proto__
:
ErrorEvent
&#13;