要将页面中的指定 div 下载为图片,可以使用 JavaScript 的 html2canvas 库将该 div 转换为图片,再通过设置 a 标签的 href 属性和 download 属性实现下载。
以下是一个简单的示例代码:
<!DOCTYPE html> <html> <head>