当前位置 : 主页 > 网页制作 > html >

execjs

来源:互联网 收集:自由互联 发布时间:2021-06-12
import execjswith open( ‘ xxx.js ‘ , ‘ rt ‘ ,encoding= ‘ utf-8 ‘ ) as f: js = execjs.compile(f.read(),cwd= ‘ ../../node_modules ‘ ) # cwd= 为加入dom和window环境供js代码运行, cnpm install jsdom ‘‘‘ const jsdo
import execjs

with open(xxx.js,rt,encoding=utf-8) as f:
            js = execjs.compile(f.read(),cwd=../../node_modules)
     # cwd= 为加入dom和window环境供js代码运行, cnpm install jsdom
‘‘‘
const jsdom = require("jsdom");
const { JSDOM } = jsdom;
const dom = new JSDOM(`<!DOCTYPE html><p>Hello world</p>`);
window = dom.window;
document = window.document;
XMLHttpRequest = window.XMLHttpRequest;

‘‘‘

        data = js.call(function,参数)
网友评论