33 lines
847 B
JavaScript
33 lines
847 B
JavaScript
const jsdom = require("jsdom");
|
||
import fs from 'fs'
|
||
import path from 'path';
|
||
import axios from "axios";
|
||
|
||
const { JSDOM } = jsdom;
|
||
|
||
const html = fs.readFileSync(path.join(path.resolve('./build'),'index.html'),'utf-8');
|
||
const { window } = new JSDOM(html);
|
||
|
||
const $ = require( "jquery" )( window )
|
||
|
||
global.window = window;
|
||
global.document = window.document;
|
||
global.navigator = window.navigator;
|
||
global.localStorage = {}
|
||
|
||
export const getDomObj = () => {
|
||
return new JSDOM(html)
|
||
}
|
||
|
||
// axios.get('https://gw.alipayobjects.com/os/lib/alipay/alex/2.0.19/bundle/alex.all.global.min.js')
|
||
// .then(response => {
|
||
// // 处理响应
|
||
// if (response) {
|
||
// // 这里你可以直接使用response.data,而不是eval
|
||
// eval(response);
|
||
// }
|
||
// })
|
||
// .catch(error => {
|
||
// console.error('Error fetching data:', error);
|
||
// });
|