{"id":24473,"date":"2024-11-21T10:03:31","date_gmt":"2024-11-21T02:03:31","guid":{"rendered":"https:\/\/fwq.ai\/blog\/24473\/"},"modified":"2024-11-21T10:03:31","modified_gmt":"2024-11-21T02:03:31","slug":"webman%ef%bc%9a%e4%b8%ba%e5%bc%80%e5%8f%91%e4%bc%98%e9%9b%85%e8%80%8c%e9%ab%98%e6%95%88%e7%9a%84%e5%89%8d%e7%ab%af%e5%ba%94%e7%94%a8%e7%a8%8b%e5%ba%8f%e6%8f%90%e4%be%9b%e6%94%af%e6%8c%81%e7%9a%84","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/24473\/","title":{"rendered":"Webman\uff1a\u4e3a\u5f00\u53d1\u4f18\u96c5\u800c\u9ad8\u6548\u7684\u524d\u7aef\u5e94\u7528\u7a0b\u5e8f\u63d0\u4f9b\u652f\u6301\u7684\u524d\u7aef\u6846\u67b6"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/465\/014\/169296310648840.jpg\" class=\"aligncenter\" title=\"Webman\uff1a\u4e3a\u5f00\u53d1\u4f18\u96c5\u800c\u9ad8\u6548\u7684\u524d\u7aef\u5e94\u7528\u7a0b\u5e8f\u63d0\u4f9b\u652f\u6301\u7684\u524d\u7aef\u6846\u67b6\u63d2\u56fe\" alt=\"Webman\uff1a\u4e3a\u5f00\u53d1\u4f18\u96c5\u800c\u9ad8\u6548\u7684\u524d\u7aef\u5e94\u7528\u7a0b\u5e8f\u63d0\u4f9b\u652f\u6301\u7684\u524d\u7aef\u6846\u67b6\u63d2\u56fe\" \/><\/p>\n<p>Webman\uff1a\u4e3a\u5f00\u53d1\u4f18\u96c5\u800c\u9ad8\u6548\u7684\u524d\u7aef\u5e94\u7528\u7a0b\u5e8f\u63d0\u4f9b\u652f\u6301\u7684\u524d\u7aef\u6846\u67b6<\/p>\n<p>Webman\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u524d\u7aef\u6846\u67b6\uff0c\u4e13\u95e8\u4e3a\u5f00\u53d1\u4f18\u96c5\u800c\u9ad8\u6548\u7684\u524d\u7aef\u5e94\u7528\u7a0b\u5e8f\u800c\u8bbe\u8ba1\u3002\u5b83\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u7684\u5de5\u5177\u548c\u7ec4\u4ef6\uff0c\u5e2e\u52a9\u5f00\u53d1\u4eba\u5458\u5feb\u901f\u6784\u5efa\u73b0\u4ee3\u5316\u7684\u524d\u7aef\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u4e14\u5177\u6709\u826f\u597d\u7684\u53ef\u7ef4\u62a4\u6027\u548c\u6269\u5c55\u6027\u3002<\/p>\n<p>Webman\u7684\u8bbe\u8ba1\u7406\u5ff5\u662f\u7b80\u5355\u800c\u7075\u6d3b\u3002\u5b83\u63d0\u4f9b\u4e86\u4e00\u5957\u7b80\u6d01\u800c\u5f3a\u5927\u7684API\uff0c\u4f7f\u5f97\u5f00\u53d1\u4eba\u5458\u53ef\u4ee5\u8f7b\u677e\u5730\u6784\u5efa\u590d\u6742\u7684\u524d\u7aef\u5e94\u7528\u7a0b\u5e8f\u3002\u540c\u65f6\uff0cWebman\u8fd8\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u6269\u5c55\u673a\u5236\uff0c\u5141\u8bb8\u5f00\u53d1\u4eba\u5458\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u8fdb\u884c\u5b9a\u5236\u548c\u6269\u5c55\u3002<\/p>\n<p>\u4e0b\u9762\u662f\u4e00\u4e2a\u57fa\u672c\u7684Webman\u793a\u4f8b\uff0c\u5c55\u793a\u4e86\u5982\u4f55\u4f7f\u7528Webman\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u5f85\u529e\u4e8b\u9879\u5e94\u7528\u7a0b\u5e8f\uff1a<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>import { createApp, reactive } from \"webman\";\n\n\/\/ \u521b\u5efa\u4e00\u4e2a\u5e94\u7528\u5b9e\u4f8b\nconst app = createApp();\n\n\/\/ \u521b\u5efa\u4e00\u4e2a\u6570\u636e\u6a21\u578b\nconst todoList = reactive({\n  items: [],\n  add(item) {\n    this.items.push(item);\n  },\n  remove(index) {\n    this.items.splice(index, 1);\n  },\n});\n\n\/\/ \u521b\u5efa\u4e00\u4e2a\u9875\u9762\u7ec4\u4ef6\nconst TodoApp = {\n  template: `\n    &lt;div&gt;\n      &lt;h1&gt;Todo List&lt;\/h1&gt;\n      &lt;ul&gt;\n&lt;li v-for=\"(item, index) in items\" :key=\"index\"&gt;\n          {{ item }}\n          &lt;button&gt;Remove&lt;\/button&gt;\n        &lt;\/li&gt;\n      &lt;\/ul&gt;\n&lt;input v-model=\"newItem\" type=\"text\"&gt;&lt;button&gt;Add&lt;\/button&gt;\n    &lt;\/div&gt;\n  `,\n  data() {\n    return {\n      items: todoList.items,\n      newItem: \"\",\n    };\n  },\n  methods: {\n    add(item) {\n      todoList.add(item);\n      this.newItem = \"\";\n    },\n    remove(index) {\n      todoList.remove(index);\n    },\n  },\n};\n\n\/\/ \u5c06\u9875\u9762\u7ec4\u4ef6\u6dfb\u52a0\u5230\u5e94\u7528\u5b9e\u4f8b\napp.component(\"todo-app\", TodoApp);\n\n\/\/ \u542f\u52a8\u5e94\u7528\napp.mount(\"#app\");<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u5bfc\u5165\u4e86Webman\u7684\u4e00\u4e9b\u6838\u5fc3API\uff0c\u5305\u62eccreateApp\u548creactive\u3002\u7136\u540e\uff0c\u6211\u4eec\u4f7f\u7528createApp\u521b\u5efa\u4e86\u4e00\u4e2a\u5e94\u7528\u5b9e\u4f8b\uff0c\u5e76\u4f7f\u7528reactive\u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3atodoList\u7684\u6570\u636e\u6a21\u578b\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3aTodoApp\u7684\u9875\u9762\u7ec4\u4ef6\uff0c\u7ec4\u4ef6\u4e2d\u5305\u62ec\u4e00\u4e2a\u5f85\u529e\u4e8b\u9879\u5217\u8868\u3001\u4e00\u4e2a\u8f93\u5165\u6846\u548c\u4e24\u4e2a\u6309\u94ae\u3002\u6211\u4eec\u901a\u8fc7v-for\u6307\u4ee4\u6765\u6e32\u67d3\u5f85\u529e\u4e8b\u9879\u5217\u8868\uff0c\u5e76\u4f7f\u7528v-model\u6307\u4ee4\u5c06\u8f93\u5165\u6846\u548c\u6570\u636e\u6a21\u578b\u7ed1\u5b9a\u8d77\u6765\u3002<\/p>\n<p>\u6700\u540e\uff0c\u6211\u4eec\u5c06\u9875\u9762\u7ec4\u4ef6\u6dfb\u52a0\u5230\u5e94\u7528\u5b9e\u4f8b\u4e2d\uff0c\u5e76\u901a\u8fc7mount\u65b9\u6cd5\u5c06\u5e94\u7528\u5b9e\u4f8b\u6302\u8f7d\u5230DOM\u4e2d\u7684\u4e00\u4e2a\u5bb9\u5668\u4e0a\uff08\u8fd9\u91cc\u4f7f\u7528\u4e86\u4e00\u4e2aid\u4e3aapp\u7684div\u5143\u7d20\uff09\u3002<\/p>\n<p>\u901a\u8fc7\u4ee5\u4e0a\u4ee3\u7801\u793a\u4f8b\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230Webman\u7684\u7b80\u6d01\u548c\u6613\u7528\u4e4b\u5904\u3002\u4f7f\u7528Webman\uff0c\u6211\u4eec\u53ef\u4ee5\u8f7b\u677e\u5730\u6784\u5efa\u51fa\u4e00\u4e2a\u529f\u80fd\u5b8c\u5584\u7684\u5f85\u529e\u4e8b\u9879\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u4e14\u5177\u6709\u826f\u597d\u7684\u53ef\u7ef4\u62a4\u6027\u548c\u6269\u5c55\u6027\u3002<\/p>\n<p>\u9664\u4e86\u4e0a\u8ff0\u793a\u4f8b\u4e2d\u4f7f\u7528\u7684API\u548c\u7ec4\u4ef6\uff0cWebman\u8fd8\u63d0\u4f9b\u4e86\u8bb8\u591a\u5176\u4ed6\u529f\u80fd\u548c\u5de5\u5177\uff0c\u5305\u62ec\u8def\u7531\u7ba1\u7406\u3001\u72b6\u6001\u7ba1\u7406\u3001\u8868\u5355\u9a8c\u8bc1\u7b49\u3002\u5f00\u53d1\u4eba\u5458\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u9009\u62e9\u5e76\u4f7f\u7528\u8fd9\u4e9b\u529f\u80fd\u548c\u5de5\u5177\uff0c\u4ee5\u4fbf\u66f4\u597d\u5730\u5f00\u53d1\u51fa\u6ee1\u8db3\u7528\u6237\u9700\u6c42\u7684\u524d\u7aef\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>\u603b\u7ed3\u8d77\u6765\uff0cWebman\u662f\u4e00\u4e2a\u4e3a\u5f00\u53d1\u4f18\u96c5\u800c\u9ad8\u6548\u7684\u524d\u7aef\u5e94\u7528\u7a0b\u5e8f\u800c\u8bbe\u8ba1\u7684\u524d\u7aef\u6846\u67b6\u3002\u5b83\u5177\u6709\u7b80\u6d01\u3001\u7075\u6d3b\u548c\u6613\u7528\u7684\u7279\u70b9\uff0c\u5e2e\u52a9\u5f00\u53d1\u4eba\u5458\u5feb\u901f\u6784\u5efa\u73b0\u4ee3\u5316\u7684\u524d\u7aef\u5e94\u7528\u7a0b\u5e8f\u3002\u5982\u679c\u4f60\u6b63\u5728\u5bfb\u627e\u4e00\u6b3e\u5f3a\u5927\u4e14\u6613\u7528\u7684\u524d\u7aef\u6846\u67b6\uff0cWebman\u662f\u4e00\u4e2a\u4e0d\u9519\u7684\u9009\u62e9\u3002\u5c1d\u8bd5\u4e00\u4e0bWebman\uff0c\u4f53\u9a8c\u4e00\u79cd\u5168\u65b0\u7684\u524d\u7aef\u5f00\u53d1\u65b9\u5f0f\uff01<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fWebman\uff1a\u4e3a\u5f00\u53d1\u4f18\u96c5\u800c\u9ad8\u6548\u7684\u524d\u7aef\u5e94\u7528\u7a0b\u5e8f\u63d0\u4f9b\u652f\u6301\u7684\u524d\u7aef\u6846\u67b6\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Webman\uff1a\u4e3a\u5f00\u53d1\u4f18\u96c5\u800c\u9ad8\u6548\u7684\u524d\u7aef\u5e94\u7528\u7a0b\u5e8f\u63d0\u4f9b\u652f\u6301\u7684\u524d\u7aef\u6846\u67b6 Webman\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u524d\u7aef\u6846\u67b6\uff0c\u4e13\u95e8\u4e3a\u5f00\u53d1\u4f18\u96c5\u800c\u9ad8\u6548\u7684\u524d\u7aef\u5e94\u7528\u7a0b\u5e8f\u800c\u8bbe\u8ba1\u3002\u5b83\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u7684\u5de5\u5177\u548c\u7ec4\u4ef6\uff0c\u5e2e\u52a9\u5f00\u53d1\u4eba\u5458\u5feb\u901f\u6784\u5efa\u73b0\u4ee3\u5316\u7684\u524d\u7aef\u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u4e14\u5177\u6709\u826f\u597d\u7684\u53ef\u7ef4\u62a4\u6027\u548c\u6269\u5c55\u6027\u3002 Webman\u7684\u8bbe\u8ba1\u7406\u5ff5\u662f\u7b80\u5355\u800c\u7075\u6d3b\u3002\u5b83\u63d0\u4f9b\u4e86\u4e00\u5957\u7b80\u6d01\u800c\u5f3a\u5927\u7684API\uff0c\u4f7f\u5f97\u5f00\u53d1\u4eba\u5458\u53ef\u4ee5\u8f7b\u677e\u5730\u6784\u5efa\u590d\u6742\u7684\u524d\u7aef\u5e94\u7528\u7a0b\u5e8f\u3002\u540c\u65f6\uff0cWebman\u8fd8\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u6269\u5c55\u673a\u5236\uff0c\u5141\u8bb8\u5f00\u53d1\u4eba\u5458\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u8fdb\u884c\u5b9a\u5236\u548c\u6269\u5c55\u3002 \u4e0b\u9762\u662f\u4e00\u4e2a\u57fa\u672c\u7684Webman\u793a\u4f8b\uff0c\u5c55\u793a\u4e86\u5982\u4f55\u4f7f\u7528Webman\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u5f85\u529e\u4e8b\u9879\u5e94\u7528\u7a0b\u5e8f\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b import { createApp, reactive } from &#8220;webman&#8221;; \/\/ \u521b\u5efa\u4e00\u4e2a\u5e94\u7528\u5b9e\u4f8b const app = createApp(); \/\/ \u521b\u5efa\u4e00\u4e2a\u6570\u636e\u6a21\u578b const todoList = reactive({ items: [], add(item) { this.items.push(item); }, remove(index) { this.items.splice(index, 1); }, }); \/\/ \u521b\u5efa\u4e00\u4e2a\u9875\u9762\u7ec4\u4ef6 const TodoApp = { template: ` &lt;div&gt; &lt;h1&gt;Todo List&lt;\/h1&gt; &lt;ul&gt; &lt;li v-for=&#8221;(item, index) in items&#8221; :key=&#8221;index&#8221;&gt; {{ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-24473","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/24473","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=24473"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/24473\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=24473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=24473"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=24473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}