当前位置:网站首页>Error reported using worker: uncaught domexception: failed to construct 'worker': script at***

Error reported using worker: uncaught domexception: failed to construct 'worker': script at***

2022-06-24 00:56:00 AzeShinja

Problem solving process :

The screenshot of error reporting is as follows :

 Insert picture description here

There is a high probability of this error vue.config Configuration problem of , First put my original configuration

 //  Solve the packaging error 
  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;
    });
  },

Bloggers have found the above configuration on the Internet , When you find that you have it, start the project browser and report Error in title .
Simply use Baidu translation to translate : On safety grounds worker It can't run locally balabala. Then the direction deviated a little , I have read many articles and said that I should worker Deploy files to the server . These people are numb at first sight , This is not quite outrageous ?

The key to the solution :

Last , The following configurations have been found to solve the problem of error reporting and can be used ,it works!
There are some articles on the Internet that do not options Call to , So an error is reported after using their code . The specific reason is that I don't know why I add... Because of my limited technology options That solves the problem =.= It's a little pity , I'm still curious . If any enthusiastic netizens know about it, please give me some advice !

 Insert picture description here

 .options({
        inline: 'fallback',
        filename: 'workerName.[hash].worker.js',
      })

Add this options It solves the problem of error reporting

Digression

I tried it before worker-plugin Is it possible not to configure so many , But I reported an error in the process of using it and didn't solve it . Finally, the configuration was done honestly =.= Don't forget to introduce worker-loader!!

原网站

版权声明
本文为[AzeShinja]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/175/202206232227086410.html

随机推荐