{"id":56293,"date":"2025-08-14T16:15:11","date_gmt":"2025-08-14T08:15:11","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/56293.html"},"modified":"2025-08-14T16:15:11","modified_gmt":"2025-08-14T08:15:11","slug":"%e9%a1%b5%e9%9d%a2%e5%bc%80%e5%8f%91%e5%b0%8f%e6%b8%b8%e6%88%8f%e8%b4%aa%e5%90%83%e8%9b%87%e7%ba%af%e5%89%8d%e7%ab%af%e4%bb%a3%e7%a0%81html%e8%84%9a%e6%9c%ac%e5%bc%80%e5%8f%91","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/56293.html","title":{"rendered":"\u9875\u9762\u5f00\u53d1\u5c0f\u6e38\u620f\u8d2a\u5403\u86c7\u7eaf\u524d\u7aef\u4ee3\u7801html\u811a\u672c\u5f00\u53d1"},"content":{"rendered":"<p>\u4fdd\u5b58\u4ee3\u7801\u4e3ahtml\u6587\u4ef6&#xff0c;\u53cc\u51fb\u6253\u5f00\u5373\u53ef<\/p>\n<p>&lt;!DOCTYPE html&gt;<br \/>\n&lt;html lang&#061;&#034;zh-CN&#034;&gt;<br \/>\n&lt;head&gt;<br \/>\n    &lt;meta charset&#061;&#034;UTF-8&#034;&gt;<br \/>\n    &lt;meta name&#061;&#034;viewport&#034; content&#061;&#034;width&#061;device-width, initial-scale&#061;1.0&#034;&gt;<br \/>\n    &lt;title&gt;\u73b0\u4ee3\u8d2a\u5403\u86c7 | Snake Game&lt;\/title&gt;<br \/>\n    &lt;script src&#061;&#034;https:\/\/cdn.tailwindcss.com&#034;&gt;&lt;\/script&gt;<br \/>\n    &lt;link href&#061;&#034;https:\/\/cdn.jsdelivr.net\/npm\/font-awesome&#064;4.7.0\/css\/font-awesome.min.css&#034; rel&#061;&#034;stylesheet&#034;&gt;<\/p>\n<p>    &lt;script&gt;<br \/>\n        tailwind.config &#061; {<br \/>\n            theme: {<br \/>\n                extend: {<br \/>\n                    colors: {<br \/>\n                        primary: &#039;#4ADE80&#039;, \/\/ \u86c7\u7684\u989c\u8272-\u7eff\u8272<br \/>\n                        secondary: &#039;#EF4444&#039;, \/\/ \u98df\u7269\u989c\u8272-\u7ea2\u8272<br \/>\n                        dark: &#039;#1E293B&#039;,<br \/>\n                        light: &#039;#F8FAFC&#039;<br \/>\n                    },<br \/>\n                    fontFamily: {<br \/>\n                        game: [&#039;&#034;Press Start 2P&#034;&#039;, &#039;cursive&#039;, &#039;sans-serif&#039;],<br \/>\n                        sans: [&#039;Inter&#039;, &#039;system-ui&#039;, &#039;sans-serif&#039;]<br \/>\n                    },<br \/>\n                }<br \/>\n            }<br \/>\n        }<br \/>\n    &lt;\/script&gt;<\/p>\n<p>    &lt;style type&#061;&#034;text\/tailwindcss&#034;&gt;<br \/>\n        &#064;layer utilities {<br \/>\n            .game-shadow {<br \/>\n                box-shadow: 0 0 20px rgba(74, 222, 128, 0.5);<br \/>\n            }<br \/>\n            .btn-hover {<br \/>\n                &#064;apply transition-all duration-200 hover:scale-105 active:scale-95;<br \/>\n            }<br \/>\n            .control-btn {<br \/>\n                &#064;apply w-14 h-14 md:w-16 md:h-16 rounded-lg bg-dark flex items-center justify-center text-light text-xl md:text-2xl btn-hover;<br \/>\n            }<br \/>\n        }<\/p>\n<p>        \/* \u5f15\u5165\u6e38\u620f\u98ce\u683c\u5b57\u4f53 *\/<br \/>\n        &#064;import url(&#039;https:\/\/fonts.googleapis.com\/css2?family&#061;Press&#043;Start&#043;2P&amp;display&#061;swap&#039;);<br \/>\n    &lt;\/style&gt;<br \/>\n&lt;\/head&gt;<br \/>\n&lt;body class&#061;&#034;bg-gradient-to-br from-dark to-slate-800 min-h-screen text-light flex flex-col items-center justify-center p-4 font-sans&#034;&gt;<br \/>\n    &lt;div class&#061;&#034;max-w-4xl w-full mx-auto&#034;&gt;<br \/>\n        &lt;!&#8211; \u6e38\u620f\u6807\u9898\u548c\u5206\u6570 &#8211;&gt;<br \/>\n        &lt;header class&#061;&#034;flex flex-col md:flex-row justify-between items-center mb-6 gap-4&#034;&gt;<br \/>\n            &lt;h1 class&#061;&#034;text-[clamp(1.5rem,3vw,2.5rem)] font-game text-primary text-center&#034;&gt;\u8d2a\u5403\u86c7&lt;\/h1&gt;<\/p>\n<p>            &lt;div class&#061;&#034;flex gap-4 w-full md:w-auto justify-center&#034;&gt;<br \/>\n                &lt;div class&#061;&#034;bg-slate-700\/50 backdrop-blur-sm px-4 py-2 rounded-lg flex items-center&#034;&gt;<br \/>\n                    &lt;i class&#061;&#034;fa fa-star text-yellow-400 mr-2&#034;&gt;&lt;\/i&gt;<br \/>\n                    &lt;span class&#061;&#034;font-bold&#034;&gt;\u5206\u6570:&lt;\/span&gt;<br \/>\n                    &lt;span id&#061;&#034;score&#034; class&#061;&#034;ml-2 text-primary&#034;&gt;0&lt;\/span&gt;<br \/>\n                &lt;\/div&gt;<\/p>\n<p>                &lt;div class&#061;&#034;bg-slate-700\/50 backdrop-blur-sm px-4 py-2 rounded-lg flex items-center&#034;&gt;<br \/>\n                    &lt;i class&#061;&#034;fa fa-trophy text-yellow-500 mr-2&#034;&gt;&lt;\/i&gt;<br \/>\n                    &lt;span class&#061;&#034;font-bold&#034;&gt;\u6700\u9ad8\u5206:&lt;\/span&gt;<br \/>\n                    &lt;span id&#061;&#034;highScore&#034; class&#061;&#034;ml-2 text-primary&#034;&gt;0&lt;\/span&gt;<br \/>\n                &lt;\/div&gt;<br \/>\n            &lt;\/div&gt;<br \/>\n        &lt;\/header&gt;<\/p>\n<p>        &lt;!&#8211; \u6e38\u620f\u5bb9\u5668 &#8211;&gt;<br \/>\n        &lt;div class&#061;&#034;relative mx-auto&#034;&gt;<br \/>\n            &lt;!&#8211; \u6e38\u620f\u753b\u5e03 &#8211;&gt;<br \/>\n            &lt;canvas id&#061;&#034;gameCanvas&#034; class&#061;&#034;bg-slate-900 rounded-lg game-shadow&#034;&gt;&lt;\/canvas&gt;<\/p>\n<p>            &lt;!&#8211; \u5f00\u59cb\u6e38\u620f\u906e\u7f69 &#8211;&gt;<br \/>\n            &lt;div id&#061;&#034;startScreen&#034; class&#061;&#034;absolute inset-0 bg-dark\/80 backdrop-blur-sm rounded-lg flex flex-col items-center justify-center gap-6 z-10&#034;&gt;<br \/>\n                &lt;h2 class&#061;&#034;text-2xl md:text-3xl font-game text-primary text-center&#034;&gt;\u5f00\u59cb\u6e38\u620f&lt;\/h2&gt;<br \/>\n                &lt;p class&#061;&#034;text-center px-6 max-w-md&#034;&gt;\u4f7f\u7528\u65b9\u5411\u952e\u6216\u5c4f\u5e55\u6309\u94ae\u63a7\u5236\u86c7\u79fb\u52a8&#xff0c;\u5403\u5230\u98df\u7269\u5f97\u5206&#xff0c;\u649e\u5230\u5899\u58c1\u6216\u81ea\u5df1\u5219\u6e38\u620f\u7ed3\u675f&lt;\/p&gt;<br \/>\n                &lt;button id&#061;&#034;startBtn&#034; class&#061;&#034;bg-primary text-dark font-bold px-6 py-3 rounded-lg btn-hover&#034;&gt;<br \/>\n                    &lt;i class&#061;&#034;fa fa-play mr-2&#034;&gt;&lt;\/i&gt;\u5f00\u59cb<br \/>\n                &lt;\/button&gt;<br \/>\n            &lt;\/div&gt;<\/p>\n<p>            &lt;!&#8211; \u6e38\u620f\u7ed3\u675f\u906e\u7f69 &#8211;&gt;<br \/>\n            &lt;div id&#061;&#034;gameOverScreen&#034; class&#061;&#034;absolute inset-0 bg-dark\/80 backdrop-blur-sm rounded-lg flex flex-col items-center justify-center gap-6 z-10 hidden&#034;&gt;<br \/>\n                &lt;h2 class&#061;&#034;text-2xl md:text-3xl font-game text-secondary text-center&#034;&gt;\u6e38\u620f\u7ed3\u675f&lt;\/h2&gt;<br \/>\n                &lt;p class&#061;&#034;text-xl&#034;&gt;\u6700\u7ec8\u5f97\u5206: &lt;span id&#061;&#034;finalScore&#034; class&#061;&#034;text-primary font-bold&#034;&gt;0&lt;\/span&gt;&lt;\/p&gt;<br \/>\n                &lt;button id&#061;&#034;restartBtn&#034; class&#061;&#034;bg-primary text-dark font-bold px-6 py-3 rounded-lg btn-hover&#034;&gt;<br \/>\n                    &lt;i class&#061;&#034;fa fa-refresh mr-2&#034;&gt;&lt;\/i&gt;\u518d\u6765\u4e00\u5c40<br \/>\n                &lt;\/button&gt;<br \/>\n            &lt;\/div&gt;<br \/>\n        &lt;\/div&gt;<\/p>\n<p>        &lt;!&#8211; \u6e38\u620f\u63a7\u5236\u533a &#8211;&gt;<br \/>\n        &lt;div class&#061;&#034;mt-8 flex flex-col gap-6&#034;&gt;<br \/>\n            &lt;!&#8211; \u96be\u5ea6\u9009\u62e9 &#8211;&gt;<br \/>\n            &lt;div class&#061;&#034;flex justify-center gap-4&#034;&gt;<br \/>\n                &lt;span class&#061;&#034;text-center self-center&#034;&gt;\u96be\u5ea6:&lt;\/span&gt;<br \/>\n                &lt;button class&#061;&#034;difficulty-btn bg-slate-700 hover:bg-slate-600 px-4 py-2 rounded-lg btn-hover&#034; data-speed&#061;&#034;150&#034;&gt;\u7b80\u5355&lt;\/button&gt;<br \/>\n                &lt;button class&#061;&#034;difficulty-btn bg-primary text-dark font-bold px-4 py-2 rounded-lg btn-hover&#034; data-speed&#061;&#034;100&#034;&gt;\u4e2d\u7b49&lt;\/button&gt;<br \/>\n                &lt;button class&#061;&#034;difficulty-btn bg-slate-700 hover:bg-slate-600 px-4 py-2 rounded-lg btn-hover&#034; data-speed&#061;&#034;60&#034;&gt;\u56f0\u96be&lt;\/button&gt;<br \/>\n            &lt;\/div&gt;<\/p>\n<p>            &lt;!&#8211; \u79fb\u52a8\u63a7\u5236\u6309\u94ae (\u4e3b\u8981\u7528\u4e8e\u79fb\u52a8\u8bbe\u5907) &#8211;&gt;<br \/>\n            &lt;div class&#061;&#034;md:hidden flex flex-col items-center gap-2&#034;&gt;<br \/>\n                &lt;div class&#061;&#034;control-btn&#034; data-direction&#061;&#034;up&#034;&gt;<br \/>\n                    &lt;i class&#061;&#034;fa fa-chevron-up&#034;&gt;&lt;\/i&gt;<br \/>\n                &lt;\/div&gt;<br \/>\n                &lt;div class&#061;&#034;flex gap-2&#034;&gt;<br \/>\n                    &lt;div class&#061;&#034;control-btn&#034; data-direction&#061;&#034;left&#034;&gt;<br \/>\n                        &lt;i class&#061;&#034;fa fa-chevron-left&#034;&gt;&lt;\/i&gt;<br \/>\n                    &lt;\/div&gt;<br \/>\n                    &lt;div class&#061;&#034;control-btn&#034; data-direction&#061;&#034;down&#034;&gt;<br \/>\n                        &lt;i class&#061;&#034;fa fa-chevron-down&#034;&gt;&lt;\/i&gt;<br \/>\n                    &lt;\/div&gt;<br \/>\n                    &lt;div class&#061;&#034;control-btn&#034; data-direction&#061;&#034;right&#034;&gt;<br \/>\n                        &lt;i class&#061;&#034;fa fa-chevron-right&#034;&gt;&lt;\/i&gt;<br \/>\n                    &lt;\/div&gt;<br \/>\n                &lt;\/div&gt;<br \/>\n            &lt;\/div&gt;<\/p>\n<p>            &lt;!&#8211; \u6e38\u620f\u8bf4\u660e &#8211;&gt;<br \/>\n            &lt;div class&#061;&#034;text-center text-sm text-slate-400&#034;&gt;<br \/>\n                &lt;p&gt;\u7535\u8111\u7aef\u4f7f\u7528\u65b9\u5411\u952e\u63a7\u5236&#xff0c;\u79fb\u52a8\u7aef\u4f7f\u7528\u5c4f\u5e55\u6309\u94ae\u63a7\u5236&lt;\/p&gt;<br \/>\n            &lt;\/div&gt;<br \/>\n        &lt;\/div&gt;<br \/>\n    &lt;\/div&gt;<\/p>\n<p>    &lt;script&gt;<br \/>\n        \/\/ \u6e38\u620f\u53d8\u91cf<br \/>\n        const canvas &#061; document.getElementById(&#039;gameCanvas&#039;);<br \/>\n        const ctx &#061; canvas.getContext(&#039;2d&#039;);<br \/>\n        const scoreElement &#061; document.getElementById(&#039;score&#039;);<br \/>\n        const highScoreElement &#061; document.getElementById(&#039;highScore&#039;);<br \/>\n        const startScreen &#061; document.getElementById(&#039;startScreen&#039;);<br \/>\n        const gameOverScreen &#061; document.getElementById(&#039;gameOverScreen&#039;);<br \/>\n        const finalScoreElement &#061; document.getElementById(&#039;finalScore&#039;);<br \/>\n        const startBtn &#061; document.getElementById(&#039;startBtn&#039;);<br \/>\n        const restartBtn &#061; document.getElementById(&#039;restartBtn&#039;);<br \/>\n        const difficultyBtns &#061; document.querySelectorAll(&#039;.difficulty-btn&#039;);<\/p>\n<p>        \/\/ \u8bbe\u7f6e\u753b\u5e03\u5c3a\u5bf8<br \/>\n        function setCanvasSize() {<br \/>\n            \/\/ \u786e\u4fdd\u753b\u5e03\u5728\u4e0d\u540c\u8bbe\u5907\u4e0a\u6709\u5408\u9002\u7684\u5927\u5c0f<br \/>\n            const maxWidth &#061; window.innerWidth &gt; 768 ? 600 : window.innerWidth &#8211; 40;<br \/>\n            const size &#061; Math.min(maxWidth, 600);<br \/>\n            canvas.width &#061; size;<br \/>\n            canvas.height &#061; size;<br \/>\n        }<\/p>\n<p>        \/\/ \u521d\u59cb\u5316\u753b\u5e03\u5c3a\u5bf8<br \/>\n        setCanvasSize();<br \/>\n        window.addEventListener(&#039;resize&#039;, setCanvasSize);<\/p>\n<p>        \/\/ \u6e38\u620f\u53c2\u6570<br \/>\n        let snake &#061; [];<br \/>\n        let food &#061; {};<br \/>\n        let direction &#061; &#039;&#039;;<br \/>\n        let nextDirection &#061; &#039;&#039;;<br \/>\n        let score &#061; 0;<br \/>\n        let highScore &#061; localStorage.getItem(&#039;snakeHighScore&#039;) || 0;<br \/>\n        let gameSpeed &#061; 100; \/\/ \u6beb\u79d2<br \/>\n        let gameInterval;<br \/>\n        let isGameRunning &#061; false;<br \/>\n        const gridSize &#061; 20; \/\/ \u7f51\u683c\u5927\u5c0f<\/p>\n<p>        \/\/ \u66f4\u65b0\u9ad8\u5206\u663e\u793a<br \/>\n        highScoreElement.textContent &#061; highScore;<\/p>\n<p>        \/\/ \u521d\u59cb\u5316\u86c7<br \/>\n        function initSnake() {<br \/>\n            const center &#061; Math.floor(canvas.width \/ gridSize \/ 2) * gridSize;<br \/>\n            snake &#061; [<br \/>\n                { x: center, y: center },<br \/>\n                { x: center &#8211; gridSize, y: center },<br \/>\n                { x: center &#8211; gridSize * 2, y: center }<br \/>\n            ];<br \/>\n            direction &#061; &#039;right&#039;;<br \/>\n            nextDirection &#061; &#039;right&#039;;<br \/>\n        }<\/p>\n<p>        \/\/ \u968f\u673a\u751f\u6210\u98df\u7269\u4f4d\u7f6e<br \/>\n        function generateFood() {<br \/>\n            \/\/ \u786e\u4fdd\u98df\u7269\u4e0d\u4f1a\u51fa\u73b0\u5728\u86c7\u8eab\u4e0a<br \/>\n            let newFood;<br \/>\n            do {<br \/>\n                newFood &#061; {<br \/>\n                    x: Math.floor(Math.random() * (canvas.width \/ gridSize)) * gridSize,<br \/>\n                    y: Math.floor(Math.random() * (canvas.height \/ gridSize)) * gridSize<br \/>\n                };<br \/>\n            } while (snake.some(segment &#061;&gt; segment.x &#061;&#061;&#061; newFood.x &amp;&amp; segment.y &#061;&#061;&#061; newFood.y));<\/p>\n<p>            food &#061; newFood;<br \/>\n        }<\/p>\n<p>        \/\/ \u7ed8\u5236\u86c7<br \/>\n        function drawSnake() {<br \/>\n            snake.forEach((segment, index) &#061;&gt; {<br \/>\n                \/\/ \u86c7\u5934\u4f7f\u7528\u4e0d\u540c\u7684\u989c\u8272<br \/>\n                if (index &#061;&#061;&#061; 0) {<br \/>\n                    ctx.fillStyle &#061; &#039;#22c55e&#039;; \/\/ \u6df1\u7eff\u8272<br \/>\n                } else {<br \/>\n                    \/\/ \u86c7\u8eab\u9010\u6e10\u53d8\u8272<br \/>\n                    const greenValue &#061; 174 &#8211; index * 5;<br \/>\n                    ctx.fillStyle &#061; &#096;rgb(74, ${Math.max(greenValue, 100)}, 128)&#096;;<br \/>\n                }<\/p>\n<p>                ctx.fillRect(segment.x, segment.y, gridSize &#8211; 1, gridSize &#8211; 1);<\/p>\n<p>                \/\/ \u86c7\u5934\u7ed8\u5236\u773c\u775b<br \/>\n                if (index &#061;&#061;&#061; 0) {<br \/>\n                    ctx.fillStyle &#061; &#039;#fff&#039;;<br \/>\n                    const eyeSize &#061; gridSize \/ 5;<\/p>\n<p>                    switch (direction) {<br \/>\n                        case &#039;right&#039;:<br \/>\n                            ctx.fillRect(segment.x &#043; gridSize &#8211; eyeSize * 2, segment.y &#043; eyeSize, eyeSize, eyeSize);<br \/>\n                            ctx.fillRect(segment.x &#043; gridSize &#8211; eyeSize * 2, segment.y &#043; gridSize &#8211; eyeSize * 2, eyeSize, eyeSize);<br \/>\n                            break;<br \/>\n                        case &#039;left&#039;:<br \/>\n                            ctx.fillRect(segment.x &#043; eyeSize, segment.y &#043; eyeSize, eyeSize, eyeSize);<br \/>\n                            ctx.fillRect(segment.x &#043; eyeSize, segment.y &#043; gridSize &#8211; eyeSize * 2, eyeSize, eyeSize);<br \/>\n                            break;<br \/>\n                        case &#039;up&#039;:<br \/>\n                            ctx.fillRect(segment.x &#043; eyeSize, segment.y &#043; eyeSize, eyeSize, eyeSize);<br \/>\n                            ctx.fillRect(segment.x &#043; gridSize &#8211; eyeSize * 2, segment.y &#043; eyeSize, eyeSize, eyeSize);<br \/>\n                            break;<br \/>\n                        case &#039;down&#039;:<br \/>\n                            ctx.fillRect(segment.x &#043; eyeSize, segment.y &#043; gridSize &#8211; eyeSize * 2, eyeSize, eyeSize);<br \/>\n                            ctx.fillRect(segment.x &#043; gridSize &#8211; eyeSize * 2, segment.y &#043; gridSize &#8211; eyeSize * 2, eyeSize, eyeSize);<br \/>\n                            break;<br \/>\n                    }<br \/>\n                }<br \/>\n            });<br \/>\n        }<\/p>\n<p>        \/\/ \u7ed8\u5236\u98df\u7269<br \/>\n        function drawFood() {<br \/>\n            ctx.fillStyle &#061; &#039;#EF4444&#039;; \/\/ \u7ea2\u8272\u98df\u7269<\/p>\n<p>            \/\/ \u7ed8\u5236\u82f9\u679c\u5f62\u72b6<br \/>\n            ctx.beginPath();<br \/>\n            ctx.arc(<br \/>\n                food.x &#043; gridSize \/ 2,<br \/>\n                food.y &#043; gridSize \/ 2,<br \/>\n                gridSize \/ 2 &#8211; 1,<br \/>\n                0,<br \/>\n                Math.PI * 2<br \/>\n            );<br \/>\n            ctx.fill();<\/p>\n<p>            \/\/ \u7ed8\u5236\u82f9\u679c\u67c4<br \/>\n            ctx.fillStyle &#061; &#039;#8B4513&#039;;<br \/>\n            ctx.beginPath();<br \/>\n            ctx.moveTo(food.x &#043; gridSize \/ 2, food.y);<br \/>\n            ctx.lineTo(food.x &#043; gridSize \/ 2 &#043; 5, food.y &#8211; 5);<br \/>\n            ctx.lineTo(food.x &#043; gridSize \/ 2 &#043; 3, food.y &#8211; 5);<br \/>\n            ctx.lineTo(food.x &#043; gridSize \/ 2, food.y &#8211; 1);<br \/>\n            ctx.fill();<br \/>\n        }<\/p>\n<p>        \/\/ \u79fb\u52a8\u86c7<br \/>\n        function moveSnake() {<br \/>\n            \/\/ \u66f4\u65b0\u65b9\u5411<br \/>\n            direction &#061; nextDirection;<\/p>\n<p>            \/\/ \u521b\u5efa\u65b0\u7684\u5934\u90e8<br \/>\n            const head &#061; { &#8230;snake[0] };<\/p>\n<p>            \/\/ \u6839\u636e\u65b9\u5411\u79fb\u52a8\u5934\u90e8<br \/>\n            switch (direction) {<br \/>\n                case &#039;up&#039;:<br \/>\n                    head.y -&#061; gridSize;<br \/>\n                    break;<br \/>\n                case &#039;down&#039;:<br \/>\n                    head.y &#043;&#061; gridSize;<br \/>\n                    break;<br \/>\n                case &#039;left&#039;:<br \/>\n                    head.x -&#061; gridSize;<br \/>\n                    break;<br \/>\n                case &#039;right&#039;:<br \/>\n                    head.x &#043;&#061; gridSize;<br \/>\n                    break;<br \/>\n            }<\/p>\n<p>            \/\/ \u68c0\u67e5\u78b0\u649e<br \/>\n            if (<br \/>\n                head.x &lt; 0 ||<br \/>\n                head.x &gt;&#061; canvas.width ||<br \/>\n                head.y &lt; 0 ||<br \/>\n                head.y &gt;&#061; canvas.height ||<br \/>\n                snake.some(segment &#061;&gt; segment.x &#061;&#061;&#061; head.x &amp;&amp; segment.y &#061;&#061;&#061; head.y)<br \/>\n            ) {<br \/>\n                gameOver();<br \/>\n                return;<br \/>\n            }<\/p>\n<p>            \/\/ \u5c06\u65b0\u5934\u90e8\u6dfb\u52a0\u5230\u86c7<br \/>\n            snake.unshift(head);<\/p>\n<p>            \/\/ \u68c0\u67e5\u662f\u5426\u5403\u5230\u98df\u7269<br \/>\n            if (head.x &#061;&#061;&#061; food.x &amp;&amp; head.y &#061;&#061;&#061; food.y) {<br \/>\n                \/\/ \u52a0\u5206<br \/>\n                score &#043;&#061; 10;<br \/>\n                scoreElement.textContent &#061; score;<\/p>\n<p>                \/\/ \u66f4\u65b0\u9ad8\u5206<br \/>\n                if (score &gt; highScore) {<br \/>\n                    highScore &#061; score;<br \/>\n                    highScoreElement.textContent &#061; highScore;<br \/>\n                    localStorage.setItem(&#039;snakeHighScore&#039;, highScore);<br \/>\n                }<\/p>\n<p>                \/\/ \u751f\u6210\u65b0\u98df\u7269<br \/>\n                generateFood();<\/p>\n<p>                \/\/ \u64ad\u653e\u5403\u98df\u7269\u97f3\u6548<br \/>\n                playSound(&#039;eat&#039;);<br \/>\n            } else {<br \/>\n                \/\/ \u79fb\u9664\u5c3e\u90e8<br \/>\n                snake.pop();<br \/>\n            }<br \/>\n        }<\/p>\n<p>        \/\/ \u7ed8\u5236\u6e38\u620f<br \/>\n        function drawGame() {<br \/>\n            \/\/ \u6e05\u7a7a\u753b\u5e03<br \/>\n            ctx.fillStyle &#061; &#039;#0F172A&#039;; \/\/ \u6df1\u8272\u80cc\u666f<br \/>\n            ctx.fillRect(0, 0, canvas.width, canvas.height);<\/p>\n<p>            \/\/ \u7ed8\u5236\u7f51\u683c&#xff08;\u8f7b\u5fae\u7684\u7f51\u683c\u7ebf&#xff09;<br \/>\n            ctx.strokeStyle &#061; &#039;rgba(148, 163, 184, 0.1)&#039;;<br \/>\n            ctx.lineWidth &#061; 1;<\/p>\n<p>            \/\/ \u7ed8\u5236\u6c34\u5e73\u7ebf<br \/>\n            for (let y &#061; 0; y &lt; canvas.height; y &#043;&#061; gridSize) {<br \/>\n                ctx.beginPath();<br \/>\n                ctx.moveTo(0, y);<br \/>\n                ctx.lineTo(canvas.width, y);<br \/>\n                ctx.stroke();<br \/>\n            }<\/p>\n<p>            \/\/ \u7ed8\u5236\u5782\u76f4\u7ebf<br \/>\n            for (let x &#061; 0; x &lt; canvas.width; x &#043;&#061; gridSize) {<br \/>\n                ctx.beginPath();<br \/>\n                ctx.moveTo(x, 0);<br \/>\n                ctx.lineTo(x, canvas.height);<br \/>\n                ctx.stroke();<br \/>\n            }<\/p>\n<p>            \/\/ \u7ed8\u5236\u86c7\u548c\u98df\u7269<br \/>\n            drawSnake();<br \/>\n            drawFood();<br \/>\n        }<\/p>\n<p>        \/\/ \u6e38\u620f\u5faa\u73af<br \/>\n        function gameLoop() {<br \/>\n            moveSnake();<br \/>\n            drawGame();<br \/>\n        }<\/p>\n<p>        \/\/ \u5f00\u59cb\u6e38\u620f<br \/>\n        function startGame() {<br \/>\n            if (isGameRunning) return;<\/p>\n<p>            \/\/ \u91cd\u7f6e\u6e38\u620f\u72b6\u6001<br \/>\n            score &#061; 0;<br \/>\n            scoreElement.textContent &#061; score;<br \/>\n            startScreen.classList.add(&#039;hidden&#039;);<br \/>\n            gameOverScreen.classList.add(&#039;hidden&#039;);<\/p>\n<p>            \/\/ \u521d\u59cb\u5316\u6e38\u620f<br \/>\n            initSnake();<br \/>\n            generateFood();<\/p>\n<p>            \/\/ \u5f00\u59cb\u6e38\u620f\u5faa\u73af<br \/>\n            isGameRunning &#061; true;<br \/>\n            clearInterval(gameInterval);<br \/>\n            gameInterval &#061; setInterval(gameLoop, gameSpeed);<\/p>\n<p>            \/\/ \u64ad\u653e\u5f00\u59cb\u97f3\u6548<br \/>\n            playSound(&#039;start&#039;);<br \/>\n        }<\/p>\n<p>        \/\/ \u6e38\u620f\u7ed3\u675f<br \/>\n        function gameOver() {<br \/>\n            isGameRunning &#061; false;<br \/>\n            clearInterval(gameInterval);<\/p>\n<p>            \/\/ \u663e\u793a\u6e38\u620f\u7ed3\u675f\u753b\u9762<br \/>\n            finalScoreElement.textContent &#061; score;<br \/>\n            gameOverScreen.classList.remove(&#039;hidden&#039;);<\/p>\n<p>            \/\/ \u64ad\u653e\u6e38\u620f\u7ed3\u675f\u97f3\u6548<br \/>\n            playSound(&#039;gameOver&#039;);<br \/>\n        }<\/p>\n<p>        \/\/ \u5904\u7406\u65b9\u5411\u63a7\u5236<br \/>\n        function handleDirection(newDirection) {<br \/>\n            \/\/ \u9632\u6b62180\u5ea6\u8f6c\u5411<br \/>\n            if (<br \/>\n                (newDirection &#061;&#061;&#061; &#039;up&#039; &amp;&amp; direction &#061;&#061;&#061; &#039;down&#039;) ||<br \/>\n                (newDirection &#061;&#061;&#061; &#039;down&#039; &amp;&amp; direction &#061;&#061;&#061; &#039;up&#039;) ||<br \/>\n                (newDirection &#061;&#061;&#061; &#039;left&#039; &amp;&amp; direction &#061;&#061;&#061; &#039;right&#039;) ||<br \/>\n                (newDirection &#061;&#061;&#061; &#039;right&#039; &amp;&amp; direction &#061;&#061;&#061; &#039;left&#039;)<br \/>\n            ) {<br \/>\n                return;<br \/>\n            }<\/p>\n<p>            nextDirection &#061; newDirection;<br \/>\n        }<\/p>\n<p>        \/\/ \u64ad\u653e\u7b80\u5355\u97f3\u6548&#xff08;\u4f7f\u7528Web Audio API&#xff09;<br \/>\n        function playSound(type) {<br \/>\n            try {<br \/>\n                const audioContext &#061; new (window.AudioContext || window.webkitAudioContext)();<br \/>\n                const oscillator &#061; audioContext.createOscillator();<br \/>\n                const gainNode &#061; audioContext.createGain();<\/p>\n<p>                oscillator.connect(gainNode);<br \/>\n                gainNode.connect(audioContext.destination);<\/p>\n<p>                \/\/ \u6839\u636e\u4e0d\u540c\u7c7b\u578b\u8bbe\u7f6e\u4e0d\u540c\u7684\u97f3\u6548<br \/>\n                switch (type) {<br \/>\n                    case &#039;start&#039;:<br \/>\n                        oscillator.type &#061; &#039;sine&#039;;<br \/>\n                        oscillator.frequency.setValueAtTime(330, audioContext.currentTime);<br \/>\n                        oscillator.frequency.exponentialRampToValueAtTime(0.001, audioContext.currentTime &#043; 0.5);<br \/>\n                        gainNode.gain.setValueAtTime(0.1, audioContext.currentTime);<br \/>\n                        oscillator.start();<br \/>\n                        oscillator.stop(audioContext.currentTime &#043; 0.5);<br \/>\n                        break;<br \/>\n                    case &#039;eat&#039;:<br \/>\n                        oscillator.type &#061; &#039;sine&#039;;<br \/>\n                        oscillator.frequency.setValueAtTime(523.25, audioContext.currentTime);<br \/>\n                        oscillator.frequency.exponentialRampToValueAtTime(783.99, audioContext.currentTime &#043; 0.1);<br \/>\n                        gainNode.gain.setValueAtTime(0.1, audioContext.currentTime);<br \/>\n                        gainNode.gain.exponentialRampToValueAtTime(0.001, audioContext.currentTime &#043; 0.1);<br \/>\n                        oscillator.start();<br \/>\n                        oscillator.stop(audioContext.currentTime &#043; 0.1);<br \/>\n                        break;<br \/>\n                    case &#039;gameOver&#039;:<br \/>\n                        oscillator.type &#061; &#039;sine&#039;;<br \/>\n                        oscillator.frequency.setValueAtTime(220, audioContext.currentTime);<br \/>\n                        oscillator.frequency.exponentialRampToValueAtTime(0.001, audioContext.currentTime &#043; 0.8);<br \/>\n                        gainNode.gain.setValueAtTime(0.1, audioContext.currentTime);<br \/>\n                        oscillator.start();<br \/>\n                        oscillator.stop(audioContext.currentTime &#043; 0.8);<br \/>\n                        break;<br \/>\n                }<br \/>\n            } catch (e) {<br \/>\n                \/\/ \u6d4f\u89c8\u5668\u4e0d\u652f\u6301Web Audio API\u65f6\u4e0d\u505a\u5904\u7406<br \/>\n                console.log(&#039;\u97f3\u6548\u64ad\u653e\u5931\u8d25:&#039;, e);<br \/>\n            }<br \/>\n        }<\/p>\n<p>        \/\/ \u4e8b\u4ef6\u76d1\u542c<br \/>\n        startBtn.addEventListener(&#039;click&#039;, startGame);<br \/>\n        restartBtn.addEventListener(&#039;click&#039;, startGame);<\/p>\n<p>        \/\/ \u952e\u76d8\u63a7\u5236<br \/>\n        document.addEventListener(&#039;keydown&#039;, (e) &#061;&gt; {<br \/>\n            switch (e.key) {<br \/>\n                case &#039;ArrowUp&#039;:<br \/>\n                    handleDirection(&#039;up&#039;);<br \/>\n                    break;<br \/>\n                case &#039;ArrowDown&#039;:<br \/>\n                    handleDirection(&#039;down&#039;);<br \/>\n                    break;<br \/>\n                case &#039;ArrowLeft&#039;:<br \/>\n                    handleDirection(&#039;left&#039;);<br \/>\n                    break;<br \/>\n                case &#039;ArrowRight&#039;:<br \/>\n                    handleDirection(&#039;right&#039;);<br \/>\n                    break;<br \/>\n                case &#039; &#039;: \/\/ \u7a7a\u683c\u952e\u5f00\u59cb\/\u6682\u505c\u6e38\u620f<br \/>\n                    if (isGameRunning) {<br \/>\n                        clearInterval(gameInterval);<br \/>\n                        isGameRunning &#061; false;<br \/>\n                    } else if (!startScreen.classList.contains(&#039;hidden&#039;) || !gameOverScreen.classList.contains(&#039;hidden&#039;)) {<br \/>\n                        startGame();<br \/>\n                    }<br \/>\n                    break;<br \/>\n            }<br \/>\n        });<\/p>\n<p>        \/\/ \u5c4f\u5e55\u63a7\u5236\u6309\u94ae<br \/>\n        document.querySelectorAll(&#039;.control-btn&#039;).forEach(btn &#061;&gt; {<br \/>\n            btn.addEventListener(&#039;click&#039;, () &#061;&gt; {<br \/>\n                handleDirection(btn.dataset.direction);<br \/>\n            });<br \/>\n        });<\/p>\n<p>        \/\/ \u96be\u5ea6\u9009\u62e9<br \/>\n        difficultyBtns.forEach(btn &#061;&gt; {<br \/>\n            btn.addEventListener(&#039;click&#039;, () &#061;&gt; {<br \/>\n                \/\/ \u66f4\u65b0UI<br \/>\n                difficultyBtns.forEach(b &#061;&gt; {<br \/>\n                    b.classList.remove(&#039;bg-primary&#039;, &#039;text-dark&#039;, &#039;font-bold&#039;);<br \/>\n                    b.classList.add(&#039;bg-slate-700&#039;, &#039;hover:bg-slate-600&#039;);<br \/>\n                });<br \/>\n                btn.classList.remove(&#039;bg-slate-700&#039;, &#039;hover:bg-slate-600&#039;);<br \/>\n                btn.classList.add(&#039;bg-primary&#039;, &#039;text-dark&#039;, &#039;font-bold&#039;);<\/p>\n<p>                \/\/ \u66f4\u65b0\u6e38\u620f\u901f\u5ea6<br \/>\n                gameSpeed &#061; parseInt(btn.dataset.speed);<\/p>\n<p>                \/\/ \u5982\u679c\u6e38\u620f\u6b63\u5728\u8fd0\u884c&#xff0c;\u66f4\u65b0\u95f4\u9694<br \/>\n                if (isGameRunning) {<br \/>\n                    clearInterval(gameInterval);<br \/>\n                    gameInterval &#061; setInterval(gameLoop, gameSpeed);<br \/>\n                }<br \/>\n            });<br \/>\n        });<\/p>\n<p>        \/\/ \u89e6\u6478\u6ed1\u52a8\u63a7\u5236&#xff08;\u79fb\u52a8\u8bbe\u5907&#xff09;<br \/>\n        let touchStartX &#061; 0;<br \/>\n        let touchStartY &#061; 0;<\/p>\n<p>        canvas.addEventListener(&#039;touchstart&#039;, (e) &#061;&gt; {<br \/>\n            touchStartX &#061; e.touches[0].clientX;<br \/>\n            touchStartY &#061; e.touches[0].clientY;<br \/>\n            e.preventDefault(); \/\/ \u9632\u6b62\u89e6\u6478\u4e8b\u4ef6\u5f71\u54cd\u9875\u9762\u6eda\u52a8<br \/>\n        }, { passive: false });<\/p>\n<p>        canvas.addEventListener(&#039;touchmove&#039;, (e) &#061;&gt; {<br \/>\n            e.preventDefault(); \/\/ \u9632\u6b62\u89e6\u6478\u4e8b\u4ef6\u5f71\u54cd\u9875\u9762\u6eda\u52a8<br \/>\n        }, { passive: false });<\/p>\n<p>        canvas.addEventListener(&#039;touchend&#039;, (e) &#061;&gt; {<br \/>\n            if (!isGameRunning) return;<\/p>\n<p>            const touchEndX &#061; e.changedTouches[0].clientX;<br \/>\n            const touchEndY &#061; e.changedTouches[0].clientY;<\/p>\n<p>            const diffX &#061; touchEndX &#8211; touchStartX;<br \/>\n            const diffY &#061; touchEndY &#8211; touchStartY;<\/p>\n<p>            \/\/ \u786e\u5b9a\u6ed1\u52a8\u65b9\u5411&#xff08;\u6c34\u5e73\u8fd8\u662f\u5782\u76f4&#xff09;<br \/>\n            if (Math.abs(diffX) &gt; Math.abs(diffY)) {<br \/>\n                \/\/ \u6c34\u5e73\u6ed1\u52a8<br \/>\n                handleDirection(diffX &gt; 0 ? &#039;right&#039; : &#039;left&#039;);<br \/>\n            } else {<br \/>\n                \/\/ \u5782\u76f4\u6ed1\u52a8<br \/>\n                handleDirection(diffY &gt; 0 ? &#039;down&#039; : &#039;up&#039;);<br \/>\n            }<\/p>\n<p>            e.preventDefault();<br \/>\n        }, { passive: false });<\/p>\n<p>        \/\/ \u521d\u59cb\u7ed8\u5236\u5f00\u59cb\u754c\u9762\u7684\u80cc\u666f<br \/>\n        drawGame();<br \/>\n    &lt;\/script&gt;<br \/>\n&lt;\/body&gt;<br \/>\n&lt;\/html&gt;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb100\u6b21\u3002\u8fd9\u662f\u4e00\u4e2a\u57fa\u4e8eHTML5 Canvas\u7684\u73b0\u4ee3\u98ce\u683c\u8d2a\u5403\u86c7\u6e38\u620f\u5b9e\u73b0\u3002\u6e38\u620f\u91c7\u7528\u54cd\u5e94\u5f0f\u8bbe\u8ba1\uff0c\u9002\u914d\u4e0d\u540c\u8bbe\u5907\u5c4f\u5e55\u3002\u4e3b\u8981\u529f\u80fd\u5305\u62ec\uff1a1) \u901a\u8fc7\u952e\u76d8\u6216\u89e6\u6478\u5c4f\u63a7\u5236\u86c7\u7684\u79fb\u52a8\u65b9\u5411\uff1b2) \u4e09\u79cd\u53ef\u9009\u96be\u5ea6\u7ea7\u522b(\u7b80\u5355\/\u4e2d\u7b49\/\u56f0\u96be)\uff1b3) \u5b9e\u65f6\u8ba1\u5206\u7cfb\u7edf\u548c\u6700\u9ad8\u5206\u8bb0\u5f55(\u4f7f\u7528localStorage\u5b58\u50a8)\uff1b4) \u6e38\u620f\u5f00\u59cb\/\u7ed3\u675f\u754c\u9762\uff1b5) \u89c6\u89c9\u7f8e\u5316\u6548\u679c(\u6e10\u53d8\u8272\u86c7\u8eab\u3001\u7f51\u683c\u80cc\u666f\u3001\u82f9\u679c\u5f62\u72b6\u98df\u7269\u7b49)\uff1b6) \u7b80\u5355\u7684\u97f3\u6548\u53cd\u9988\u3002\u6e38\u620f\u903b\u8f91\u5b8c\u6574\uff0c\u5305\u542b\u78b0\u649e\u68c0\u6d4b\u3001\u98df\u7269\u751f\u6210\u3001\u86c7\u8eab\u589e\u957f\u7b49\u7ecf\u5178\u8d2a\u5403\u86c7\u6e38\u620f\u673a\u5236\u3002\u4ee3\u7801\u7ed3\u6784\u6e05\u6670\uff0c\u4f7f\u7528\u4e86Tailwind CSS\u6846\u67b6\u5b9e\u73b0\u73b0\u4ee3\u5316UI\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[567,87],"topic":[],"class_list":["post-56293","post","type-post","status-publish","format-standard","hentry","category-server","tag-html","tag-87"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u9875\u9762\u5f00\u53d1\u5c0f\u6e38\u620f\u8d2a\u5403\u86c7\u7eaf\u524d\u7aef\u4ee3\u7801html\u811a\u672c\u5f00\u53d1 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/56293.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u9875\u9762\u5f00\u53d1\u5c0f\u6e38\u620f\u8d2a\u5403\u86c7\u7eaf\u524d\u7aef\u4ee3\u7801html\u811a\u672c\u5f00\u53d1 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb100\u6b21\u3002\u8fd9\u662f\u4e00\u4e2a\u57fa\u4e8eHTML5 Canvas\u7684\u73b0\u4ee3\u98ce\u683c\u8d2a\u5403\u86c7\u6e38\u620f\u5b9e\u73b0\u3002\u6e38\u620f\u91c7\u7528\u54cd\u5e94\u5f0f\u8bbe\u8ba1\uff0c\u9002\u914d\u4e0d\u540c\u8bbe\u5907\u5c4f\u5e55\u3002\u4e3b\u8981\u529f\u80fd\u5305\u62ec\uff1a1) \u901a\u8fc7\u952e\u76d8\u6216\u89e6\u6478\u5c4f\u63a7\u5236\u86c7\u7684\u79fb\u52a8\u65b9\u5411\uff1b2) \u4e09\u79cd\u53ef\u9009\u96be\u5ea6\u7ea7\u522b(\u7b80\u5355\/\u4e2d\u7b49\/\u56f0\u96be)\uff1b3) \u5b9e\u65f6\u8ba1\u5206\u7cfb\u7edf\u548c\u6700\u9ad8\u5206\u8bb0\u5f55(\u4f7f\u7528localStorage\u5b58\u50a8)\uff1b4) \u6e38\u620f\u5f00\u59cb\/\u7ed3\u675f\u754c\u9762\uff1b5) \u89c6\u89c9\u7f8e\u5316\u6548\u679c(\u6e10\u53d8\u8272\u86c7\u8eab\u3001\u7f51\u683c\u80cc\u666f\u3001\u82f9\u679c\u5f62\u72b6\u98df\u7269\u7b49)\uff1b6) \u7b80\u5355\u7684\u97f3\u6548\u53cd\u9988\u3002\u6e38\u620f\u903b\u8f91\u5b8c\u6574\uff0c\u5305\u542b\u78b0\u649e\u68c0\u6d4b\u3001\u98df\u7269\u751f\u6210\u3001\u86c7\u8eab\u589e\u957f\u7b49\u7ecf\u5178\u8d2a\u5403\u86c7\u6e38\u620f\u673a\u5236\u3002\u4ee3\u7801\u7ed3\u6784\u6e05\u6670\uff0c\u4f7f\u7528\u4e86Tailwind CSS\u6846\u67b6\u5b9e\u73b0\u73b0\u4ee3\u5316UI\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/56293.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-14T08:15:11+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/56293.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/56293.html\",\"name\":\"\u9875\u9762\u5f00\u53d1\u5c0f\u6e38\u620f\u8d2a\u5403\u86c7\u7eaf\u524d\u7aef\u4ee3\u7801html\u811a\u672c\u5f00\u53d1 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-14T08:15:11+00:00\",\"dateModified\":\"2025-08-14T08:15:11+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/56293.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/56293.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/56293.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u9875\u9762\u5f00\u53d1\u5c0f\u6e38\u620f\u8d2a\u5403\u86c7\u7eaf\u524d\u7aef\u4ee3\u7801html\u811a\u672c\u5f00\u53d1\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u9875\u9762\u5f00\u53d1\u5c0f\u6e38\u620f\u8d2a\u5403\u86c7\u7eaf\u524d\u7aef\u4ee3\u7801html\u811a\u672c\u5f00\u53d1 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/56293.html","og_locale":"zh_CN","og_type":"article","og_title":"\u9875\u9762\u5f00\u53d1\u5c0f\u6e38\u620f\u8d2a\u5403\u86c7\u7eaf\u524d\u7aef\u4ee3\u7801html\u811a\u672c\u5f00\u53d1 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb100\u6b21\u3002\u8fd9\u662f\u4e00\u4e2a\u57fa\u4e8eHTML5 Canvas\u7684\u73b0\u4ee3\u98ce\u683c\u8d2a\u5403\u86c7\u6e38\u620f\u5b9e\u73b0\u3002\u6e38\u620f\u91c7\u7528\u54cd\u5e94\u5f0f\u8bbe\u8ba1\uff0c\u9002\u914d\u4e0d\u540c\u8bbe\u5907\u5c4f\u5e55\u3002\u4e3b\u8981\u529f\u80fd\u5305\u62ec\uff1a1) \u901a\u8fc7\u952e\u76d8\u6216\u89e6\u6478\u5c4f\u63a7\u5236\u86c7\u7684\u79fb\u52a8\u65b9\u5411\uff1b2) \u4e09\u79cd\u53ef\u9009\u96be\u5ea6\u7ea7\u522b(\u7b80\u5355\/\u4e2d\u7b49\/\u56f0\u96be)\uff1b3) \u5b9e\u65f6\u8ba1\u5206\u7cfb\u7edf\u548c\u6700\u9ad8\u5206\u8bb0\u5f55(\u4f7f\u7528localStorage\u5b58\u50a8)\uff1b4) \u6e38\u620f\u5f00\u59cb\/\u7ed3\u675f\u754c\u9762\uff1b5) \u89c6\u89c9\u7f8e\u5316\u6548\u679c(\u6e10\u53d8\u8272\u86c7\u8eab\u3001\u7f51\u683c\u80cc\u666f\u3001\u82f9\u679c\u5f62\u72b6\u98df\u7269\u7b49)\uff1b6) \u7b80\u5355\u7684\u97f3\u6548\u53cd\u9988\u3002\u6e38\u620f\u903b\u8f91\u5b8c\u6574\uff0c\u5305\u542b\u78b0\u649e\u68c0\u6d4b\u3001\u98df\u7269\u751f\u6210\u3001\u86c7\u8eab\u589e\u957f\u7b49\u7ecf\u5178\u8d2a\u5403\u86c7\u6e38\u620f\u673a\u5236\u3002\u4ee3\u7801\u7ed3\u6784\u6e05\u6670\uff0c\u4f7f\u7528\u4e86Tailwind CSS\u6846\u67b6\u5b9e\u73b0\u73b0\u4ee3\u5316UI\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/56293.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-14T08:15:11+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"9 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/56293.html","url":"https:\/\/www.wsisp.com\/helps\/56293.html","name":"\u9875\u9762\u5f00\u53d1\u5c0f\u6e38\u620f\u8d2a\u5403\u86c7\u7eaf\u524d\u7aef\u4ee3\u7801html\u811a\u672c\u5f00\u53d1 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-14T08:15:11+00:00","dateModified":"2025-08-14T08:15:11+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/56293.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/56293.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/56293.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u9875\u9762\u5f00\u53d1\u5c0f\u6e38\u620f\u8d2a\u5403\u86c7\u7eaf\u524d\u7aef\u4ee3\u7801html\u811a\u672c\u5f00\u53d1"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/56293","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=56293"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/56293\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=56293"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=56293"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=56293"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=56293"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}