{"id":1429,"date":"2019-09-30T21:51:34","date_gmt":"2019-09-30T13:51:34","guid":{"rendered":"https:\/\/www.develop-note.com\/blog\/?p=1429"},"modified":"2022-02-17T15:01:08","modified_gmt":"2022-02-17T07:01:08","slug":"2020ironman-svelte-custom-js","status":"publish","type":"post","link":"https:\/\/www.develop-note.com\/blog\/2019\/09\/30\/2020ironman-svelte-custom-js\/","title":{"rendered":"\u7b2c\u5341\u4e00\u5c46\u9435\u4eba\u8cfd \u524d\u7aef\u5de5\u7a0b\u5e2b\u7684\u53e6\u4e00\u500b\u9078\u64c7 svelte DAY29- \u904e\u5834\u52d5\u756b (\u516d)"},"content":{"rendered":"<h1>custom js<\/h1>\n<p>custom js \u662f\u7e7c <a href=\"https:\/\/www.develop-note.com\/blog\/2019\/09\/29\/2020ironman-svelte-custom-css\/\" title=\"custom css\">custom css<\/a> \u904e\u5834\u52d5\u756b\u5f8c\u8981\u5206\u4eab\u7684\u6587\u7ae0\uff0c\u4e4b\u524d\u5206\u4eab\u7684\u6587\u7ae0\u90fd\u662f\u7528\u5167\u5efa\u51fd\u5f0f\u5eab\u4f86\u8655\u7406\u904e\u5834\u52d5\u756b\uff0c\u6628\u5929\u7684 <a href=\"https:\/\/www.develop-note.com\/blog\/2019\/09\/29\/2020ironman-svelte-custom-css\/\" title=\"custom css\">custom css<\/a> \u662f\u5ba2\u88fd\u5316 css \u4f86\u5b8c\u6210\u904e\u5834\u52d5\u756b\uff0c\u65e2\u7136 css \u90fd\u53ef\u4ee5\u5ba2\u88fd\u5316\u4e86\uff0c\u90a3\u4eca\u5929\u4f86\u5206\u4eab\u5ba2\u88fd\u5316js\u3002<!--more--><\/p>\n<h2>custom js \u662f\u4ec0\u9ebc<\/h2>\n<p>\u9867\u540d\u601d\u7fa9\u5ba2\u88fd\u5316js\u662f\u81ea\u5b9a\u7fa9\u60f3\u8981\u7684javascript\u65b9\u6cd5\uff0c\u5728\u904e\u5834\u52d5\u756b\u4e2d\u5247\u662f\u900f\u904e\u6539\u8b8ajavascript\u4f86\u5448\u73fe\u904e\u5834\u52d5\u756b\uff0c\u7576\u7136\u9019\u9ebc\u63cf\u8ff0\u5f88\u62bd\u8c61\uff0c\u63a5\u4e0b\u4f86\u770b\u770b\u5be6\u4f5c\u7684\u4f8b\u5b50\u3002<\/p>\n<h2>custom js \u80fd\u505a\u4ec0\u9ebc<\/h2>\n<p>\u4e0b\u9762\u7528\u4e00\u500b\u6253\u5b57\u6548\u679c\u7684\u904e\u5834\u52d5\u756b\uff0c\u4e5f\u8a31\u5ba2\u88fd\u5316css\u53ef\u4ee5\u5b8c\u6210\u9019\u500b\u6548\u679c\uff0c\u4f46\u662f\u5ba2\u88fd\u5316js\u66f4\u5bb9\u6613\u5b8c\u6210\uff0c\u8acb\u5927\u5bb6\u770b\u4e00\u4e0b\u4e0b\u9762\u7684\u4f8b\u5b50\u3002<\/p>\n<pre><code class=\"language-xml\">&lt;script&gt;\n    let visible = false;\n\n    function typewriter(node, { speed = 50 }) {\n    const valid = (\n        node.childNodes.length === 1 &amp;&amp;\n        node.childNodes[0].nodeType === 3\n    );\n\n    if (!valid) {\n        throw new Error(`This transition only works on elements with a single text node child`);\n    }\n\n    const text = node.textContent;\n    const duration = text.length * speed;\n\n    return {\n        duration,\n        tick: t =&gt; {\n            const i = ~~(text.length * t);\n            node.textContent = text.slice(0, i);\n        }\n    };\n    }\n&lt;\/script&gt;\n\n&lt;label&gt;\n    &lt;input type=&quot;checkbox&quot; bind:checked={visible}&gt;\n    visible\n&lt;\/label&gt;\n\n{#if visible}\n    &lt;p in:typewriter&gt;\n        The quick brown fox jumps over the lazy dog\n    &lt;\/p&gt;\n{\/if}<\/code><\/pre>\n<p>\u4e0a\u9762\u7684\u7bc4\u4f8b\u4e3b\u8981\u662f\u85c9\u7531<code>tick<\/code>\u9019\u500b\u6bcf\u6bb5\u6642\u9593\u7684callback\u4f86\u4e0d\u65b7\u4f7f\u7528javascript\uff0c\u4f86\u66f4\u65b0\u6587\u5b57\u9577\u5ea6\u85c9\u6b64\u5b8c\u6210\u900f\u904e\u5ba2\u88fd\u5316js\u7684\u904e\u5834\u52d5\u756b\u3002<\/p>\n<h2>\u5c0f\u7d50<\/h2>\n<p>\u4eca\u5929\u85c9\u7531\u5ba2\u88fd\u5316js\u4f86\u5c07\u904e\u5834\u52d5\u756b\u544a\u4e00\u6bb5\u843d\uff0c\u660e\u5929\u8981\u5beb\u4e0b\u9435\u4eba\u6bd4\u8cfd\u7b2c\u4e09\u5341\u5929\u7684\u6587\u7ae0\uff0c\u656c\u8acb\u671f\u5f85\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>custom js custom js \u662f\u7e7c custom css \u904e\u5834\u52d5\u756b\u5f8c\u8981\u5206\u4eab\u7684\u6587\u7ae0\uff0c\u4e4b\u524d\u5206\u4eab\u7684\u6587\u7ae0\u90fd\u662f &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.develop-note.com\/blog\/2019\/09\/30\/2020ironman-svelte-custom-js\/\" class=\"more-link\">\u95b1\u8b80\u5168\u6587<span class=\"screen-reader-text\">\u3008\u7b2c\u5341\u4e00\u5c46\u9435\u4eba\u8cfd \u524d\u7aef\u5de5\u7a0b\u5e2b\u7684\u53e6\u4e00\u500b\u9078\u64c7 svelte DAY29- \u904e\u5834\u52d5\u756b (\u516d)\u3009<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[2],"tags":[160,79],"class_list":["post-1429","post","type-post","status-publish","format-standard","hentry","category-develop","tag-2019ironman","tag-svelte"],"_links":{"self":[{"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/posts\/1429","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/comments?post=1429"}],"version-history":[{"count":14,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/posts\/1429\/revisions"}],"predecessor-version":[{"id":2996,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/posts\/1429\/revisions\/2996"}],"wp:attachment":[{"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/media?parent=1429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/categories?post=1429"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/tags?post=1429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}