peixue-dev/Archive/[一次性]创建小占位图-2026-01-31.html

31 lines
841 B
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>生成占位图</title>
</head>
<body>
<h2>小程序占位图生成器</h2>
<p>在浏览器控制台运行以下代码生成1KB的占位图</p>
<script>
// 生成1x1像素的占位图Base64
const canvas = document.createElement('canvas');
canvas.width = 1;
canvas.height = 1;
const ctx = canvas.getContext('2d');
ctx.fillStyle = '#2d9687'; // 你的主题色
ctx.fillRect(0, 0, 1, 1);
// 转换为Base64
const dataUrl = canvas.toDataURL('image/jpeg', 0.1);
console.log('占位图Base64:', dataUrl);
// 可以直接在代码中使用这个Base64字符串
</script>
<h3>或者使用纯CSS方案推荐</h3>
<p>不使用图片改用CSS渐变背景</p>
</body>
</html>