{"id":1199,"date":"2019-09-05T22:10:35","date_gmt":"2019-09-05T14:10:35","guid":{"rendered":"https:\/\/www.develop-note.com\/blog\/?p=1199"},"modified":"2022-02-17T15:25:41","modified_gmt":"2022-02-17T07:25:41","slug":"2020ironman-svelte-html-javascript","status":"publish","type":"post","link":"https:\/\/www.develop-note.com\/blog\/2019\/09\/05\/2020ironman-svelte-html-javascript\/","title":{"rendered":"\u7b2c\u5341\u4e00\u5c46\u9435\u4eba\u8cfd \u524d\u7aef\u5de5\u7a0b\u5e2b\u7684\u53e6\u4e00\u500b\u9078\u64c7 svelte DAY04-\u9019\u4e0d\u5c31\u662fhtml\u8ddfjavascript\u55ce"},"content":{"rendered":"<h1>\u958b\u59cb\u64b0\u5beb svelte \u7a0b\u5f0f\u78bc<\/h1>\n<p>\u5728\u5b8c\u6210\u5b89\u88dd\u4ee5\u53ca\u5efa\u7acb\u4e00\u500b\u65b0\u5c08\u6848\u5f8c\u6211\u5011\u6e96\u5099\u958b\u59cb\u64b0\u5beb\u7b2c\u4e00\u500b\u7a0b\u5f0f\u78bc\u4e86\u3002<\/p>\n<p><!--more--><\/p>\n<h1>\u958b\u59cb\u64b0\u5beb\u4e4b\u524d<\/h1>\n<p>\u5728\u958b\u59cb\u64b0\u5beb\u4e4b\u524d\u8981\u8b93\u6240\u6709\u8b80\u8005\u77e5\u9053\uff0c\u4e4b\u6240\u4ee5\u53ef\u4ee5\u9019\u9ebc\u65b9\u4fbf\u7684\u9032\u884c\u958b\u767c\u662f\u56e0\u70ba\u6709\u5176\u4ed6\u4eba\u5e6b\u5fd9\u5efa\u7acb\u4e00\u500b\u521d\u59cb\u8a2d\u5b9a\uff0c\u6240\u4ee5\u6211\u5011\u624d\u80fd\u5c08\u6ce8\u5728\u908f\u8f2f\u4ee5\u53ca\u756b\u9762\u5448\u73fe\u4e0a\u958b\u767c\u3002<br \/>\n\u800c svelte \u7684\u539f\u7406\u662f\u900f\u904e\u7de8\u8b6f\u5668\u5c07\u6211\u5011\u6240\u5beb\u7684\u7a0b\u5f0f\u8f49\u8b6f\u6210\u7d14 javascript \u7684\u7a0b\u5f0f\u78bc\uff0c\u4e4b\u5f8c\u518d\u6211\u5011\u7684 index.html \u4f7f\u7528\u9019\u500b\u7de8\u8b6f\u5f8c\u7684 javascript \u5373\u53ef\u6e32\u67d3\u6210\u6211\u5011\u8981\u5448\u73fe\u7684\u756b\u9762\uff0c\u56e0\u6b64\u6709\u8208\u8da3\u7684\u670b\u53cb\u5011\u53ef\u4ee5\u5148\u770b\u4e00\u4e0b rollup.config.js \uff0c\u9810\u8a2d\u662f\u7528 rollup \u4f86\u8655\u7406\u9019\u5de5\u4f5c\uff0c\u5927\u5bb6\u4e5f\u53ef\u4ee5\u8a66\u8457\u4fee\u6539\u6210 webpack \u6216 babel \u4f86\u7de8\u8b6f\uff0c\u6700\u5f8c\u5e7e\u5929\u7b46\u8005\u6703\u518d\u8aaa\u660e\u4e00\u4e0b\u3002<\/p>\n<h1>\u958b\u59cb\u64b0\u5beb<\/h1>\n<p>\u5728\u4e86\u89e3\u5176\u904b\u4f5c\u539f\u7406\u63a5\u4e0b\u4f86\u8981\u958b\u59cb\u64b0\u5beb\u7a0b\u5f0f\u78bc\u4e86\u3002<\/p>\n<h2>index.html<\/h2>\n<p>\u9019\u662f\u4f7f\u7528\u8005\u7684\u9032\u5165\u9ede\uff0c\u57fa\u672c\u4e0a\u683c\u5f0f\u662f\u56fa\u5b9a\u7684\uff0c\u7c21\u55ae\u8aaa\u660e\u5c31\u662f\u5ba3\u544a header \uff0c\u4f7f\u7528\u7de8\u8b6f\u5f8c\u7684 javascript \u4ee5\u53ca css \u63a5\u4e0b\u4f86\u7684\u52d5\u4f5c\u5c31\u4ea4\u7531\u7de8\u8b6f\u5f8c\u7684 javascript \u8655\u7406\u3002\u6240\u4ee5 index.html \u5982\u4e0b\u6240\u793a\u3002<\/p>\n<pre><code class=\"language-xml\">&lt;!doctype html&gt;\n&lt;html&gt;\n&lt;head&gt;\n    &lt;meta charset=&#039;utf8&#039;&gt;\n    &lt;meta name=&#039;viewport&#039; content=&#039;width=device-width&#039;&gt;\n\n    &lt;title&gt;Svelte app&lt;\/title&gt;\n\n    &lt;link rel=&#039;icon&#039; type=&#039;image\/png&#039; href=&#039;\/favicon.png&#039;&gt;\n    &lt;link rel=&#039;stylesheet&#039; href=&#039;\/global.css&#039;&gt;\n    &lt;link rel=&#039;stylesheet&#039; href=&#039;\/bundle.css&#039;&gt;\n\n    &lt;script defer src=&#039;\/bundle.js&#039;&gt;&lt;\/script&gt;\n&lt;\/head&gt;\n\n&lt;body&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n<h2>App.svelte<\/h2>\n<p>\u9019\u500b\u5c31\u662f\u7a0b\u5f0f\u7684\u9032\u5165\u9ede\uff0c\u6240\u6709\u526f\u6a94\u540d\u70ba svelte \u90fd\u662f\u6211\u5011\u6240\u9700\u5c08\u6ce8\u7684 svelte \u7a0b\u5f0f\u78bc\uff0c\u4eca\u5929\u5148\u7c21\u55ae\u5beb\u4e00\u4e0b hello world \uff0c\u5176\u7a0b\u5f0f\u78bc\u5982\u540c\u4e0b\u5217\u6240\u793a\u3002<\/p>\n<pre><code class=\"language-html\">&lt;script&gt;\n  let name = &#039;kirai&#039;;\n&lt;\/script&gt;\n\n&lt;h1&gt;Hello {name}!&lt;\/h1&gt;<\/code><\/pre>\n<h2>main.js<\/h2>\n<p>\u9019\u90e8\u5206\u5c31\u662f\u544a\u8a34html\u8981\u600e\u9ebc\u9032\u5230 App.svelte \u8a73\u60c5\u8acb\u770b\u4ee5\u4e0b\u7a0b\u5f0f\u78bc\u3002<\/p>\n<pre><code class=\"language-javascript\">import App from &#039;.\/App.svelte&#039;;\n\nvar app = new App({\n    target: document.body\n});\n\nexport default app;<\/code><\/pre>\n<p>\u5728\u64b0\u5beb\u5b8c\u4e4b\u5f8c\u5728 vscode \u7684\u7d42\u7aef\u6a5f\u8f38\u5165\u4ee5\u4e0b\u6307\u4ee4\u5373\u53ef\u770b\u5230\u958b\u767c\u4e2d\u756b\u9762\uff0c\u518d\u4f86\u5982\u679c\u4fee\u6539\u5132\u5b58\u5f8c\u6703\u81ea\u52d5\u5237\u65b0\uff0c\u76f8\u4fe1\u5c0d\u65bc\u5927\u5bb6\u958b\u767c\u6709\u4e00\u5b9a\u7684\u5e6b\u52a9\u3002<br \/>\n\u4e0d\u904e\u9019\u50c5\u662f\u958b\u767c\u6a21\u5f0f\uff0c\u5728\u5f8c\u9762\u7684\u65e5\u5b50\u518d\u8ddf\u5927\u5bb6\u5206\u4eab\u5982\u4f55\u88fd\u9020\u767c\u4f48\u7684\u7248\u672c\u3002<\/p>\n<h1>\u5c0f\u7d50<\/h1>\n<p>\u4eca\u5929\u8ddf\u5927\u5bb6\u4ecb\u7d39 svelte \u7684\u904b\u4f5c\u539f\u7406\uff0c\u4ee5\u53ca\u7a0b\u5f0f\u7684\u7d50\u69cb\uff0c\u5728\u660e\u5929\u518d\u8ddf\u5927\u5bb6\u9032\u4e00\u6b65\u8aaa\u660e svelte \u7684\u7a0b\u5f0f\u78bc\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u958b\u59cb\u64b0\u5beb svelte \u7a0b\u5f0f\u78bc \u5728\u5b8c\u6210\u5b89\u88dd\u4ee5\u53ca\u5efa\u7acb\u4e00\u500b\u65b0\u5c08\u6848\u5f8c\u6211\u5011\u6e96\u5099\u958b\u59cb\u64b0\u5beb\u7b2c\u4e00\u500b\u7a0b\u5f0f\u78bc\u4e86\u3002<\/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-1199","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\/1199","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=1199"}],"version-history":[{"count":17,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/posts\/1199\/revisions"}],"predecessor-version":[{"id":3020,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/posts\/1199\/revisions\/3020"}],"wp:attachment":[{"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/media?parent=1199"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/categories?post=1199"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/tags?post=1199"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}