Electron——electron-vue使用webworker


前言

electron-vue框架中,我们如何使用webworker,请看下文;

worker-loader: https://v4.webpack.js.org/loaders/worker-loader/
integrating-with-es6-features: https://v4.webpack.js.org/loaders/worker-loader/#integrating-with-es6-features

内容

配置文件

  • webpack.config.js
module.exports = {
  module: {
    rules: [
      {
        test: /\.worker\.js$/,
        use: { loader: "worker-loader" },
      },
    ],
  },
};

main.js

my.worker.js

onmessage = function (event) {
  const workerResult = event.data;

  workerResult.onmessage = true;

  postMessage(workerResult);
};

效果


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM