四个工具:
- nodejs + npm
- npm安装的jsdom
- npm安装的jquery
- npm安装的browserify
网址:
browserify: https://browserify.org/
jsdom: https://github.com/jsdom/jsdom/
安装:
npm install -g jsdom
npm install -g jquery
npm install -g browserify
代码(main.js):
const { JSDOM } = require("jsdom");
const { window } = new JSDOM("");
const document = window.document;
let $ = require("jquery")(window);
globalThis.window = window;
globalThis.document = document;
globalThis["$"] = $;
不带jquery的
``` const { JSDOM } = require("jsdom"); const { window } = new JSDOM(""); const document = window.document; globalThis.window = window; globalThis.document = document; ```编译(算是?):
browserify main.js -o wdj.js
我起的名字是简写(Window Document Jquery)
让worker引入wdj.js
importScripts("wdj.js");
实际效果:
第一次写这么简洁的博文,原因是三天考完期末,有点累
标签:jquery,npm,const,dom,worker,js,window,jsdom,document From: https://www.cnblogs.com/dffxd/p/17012382.html