UNPKG

hc-demo

Version:

这是测试用例

16 lines (15 loc) 597 B
import { JSDOM } from 'jsdom'; import fs from 'node:fs'; const dom = new JSDOM(`<!DOCTYPE html><div id="app"></div>`) const document = dom.window.document; fetch('https://api.thecatapi.com/v1/images/search?limit=10&page=1').then(res => res.json()).then(data => { const app = document.getElementById('app'); data.forEach(item => { const img = document.createElement('img'); img.src = item.url; img.style.width = '200px'; img.style.height = '200px'; app.appendChild(img); }); fs.writeFileSync('index.html', dom.serialize()); })