当前位置:网站首页>使用worker报错:Uncaught DOMException: Failed to construct ‘Worker’: Script at***
使用worker报错:Uncaught DOMException: Failed to construct ‘Worker’: Script at***
2022-06-23 22:27:00 【AzeShinja】
解决问题流程:
报错截图如下:

出现这个错误大概率vue.config的配置问题,先放上我原来的配置
// 解决打包的时报错
parallel: false,
chainWebpack: (config) => {
// set worker-loader
config.module
.rule('worker')
.test(/\.worker\.js$/)
.use('worker-loader')
.loader('worker-loader')
.end();
config.module.rule('js').exclude.add(/\.worker\.js$/);
config.plugin('define').tap((args) => {
const [define] = args;
Object.assign(define, {
IS_APPLET: JSON.stringify(true),
UNIQUE_MARK: JSON.stringify(uniqueMark),
});
return args;
});
},
博主在网络上湖搜海搜搜到了如上配置,发现到手后启动项目浏览器报了 标题的错误。
简单使用百度翻译翻译一下: 处于安全考虑worker在本地无法运行啊 balabala。然后方向就有点跑偏了,看了许多文章都说要把worker文件部署到服务器上。这些一看人都麻了,这不是相当离谱?
解决关键:
最后, 找到了如下配置解决了报错可以用了,it works!
在网络上有些文章是没有options的调用,所以用了他们的代码后出现了报错。具体原因由于我技术受限没有了解清楚为什么加上options就解决了这个问题 =。= 算是一个小遗憾吧,我还是很好奇的。如果有热心网友知道请赐教!

.options({
inline: 'fallback',
filename: 'workerName.[hash].worker.js',
})
加上这个options就解决了报错
题外话
之前试了下用worker-plugin是不是就可以不用配置这么多了,但是自己使用的过程中报错了且没解决掉。最后老老实实这么配置了=。= 使用的时候别忘记引入 worker-loader!!
边栏推荐
- 9次Android面试经验总结,已收字节,阿里,高级android面试答案
- The first open-source MySQL HTAP database in China will be released soon, and the three highlights will be informed in advance that shiatomics technology will launch heavily
- SAVE: 软件分析验证和测试平台
- Revit API: schedule viewschedule
- Android App Bundle探索,客户端开发面试题目
- Dart series: using generators in dart
- 逆向工具IDA、GDB使用
- 微信小程序中three.js的canvas非全屏情况下射线检测不准确问题解决方案
- Security | warm tips: security incidents on the cloud have intensified recently. Please do a good job in backup monitoring of cloud security protection!
- New function of lightweight application server: simple experience of offline business migration by using image sharing
猜你喜欢

2. camera calibration

return、const、volatile关键字

Android AIDL:跨进程调用Service (AIDL Service),kotlininvoke函数

DO280OpenShift访问控制--管理项目和账户

Android 3年外包工面试笔记,有机会还是要去大厂学习提升,作为一个Android程序员

Notepad++ practical function sharing (common methods for replacing the end and beginning of regular lines, text comparison function, etc.)

Solve the problem of project dependency red reporting

Return, const, volatile keywords

Andorid development art exploration notes (2), cross platform applet development framework

Accompanist组件库中文指南 - Glide篇,劲爆
随机推荐
Google Earth Engine(GEE)——NDVI、NDWI和NDBI用来进行增加分类精度的验证结果(随机森林和cart分类)
Mip-NeRF:抗混叠的多尺度神经辐射场ICCV2021
Summary of common register bit operation modes in MCU
Another short video app with high imitation and eye opening
Batch renaming of images by MATLAB
跟着CTF-wiki学pwn——ret2text
Android - basics you need to know about JNI development, interview questions for Android engineers
Interview notes for Android outsourcing workers for 3 years. I still need to go to a large factory to learn and improve. As an Android programmer
Security | warm tips: security incidents on the cloud have intensified recently. Please do a good job in backup monitoring of cloud security protection!
How much business do you need to know to do data analysis
What do NLP engineers do? What is the work content?
js 语言 精度问题
Shuttle global levitation button
Andorid development art exploration notes (2), cross platform applet development framework
合成大西瓜小游戏微信小程序源码/微信游戏小程序源码
如何利用數倉創建時序錶
Tiktok practice ~ one click registration and login process of mobile phone number and password (restrict mobile terminal login)
[technical grass planting] use the shared image function to realize the offline switching from CVM to LH
被同事坑到周末加班, 没见过把Redis用成这个鬼样子的。。。
超标量处理器设计 姚永斌 第3章 虚拟存储器 --3.1~3.2 小节摘录