{"id":24080,"date":"2024-11-21T15:58:49","date_gmt":"2024-11-21T07:58:49","guid":{"rendered":"https:\/\/fwq.ai\/blog\/24080\/"},"modified":"2024-11-21T15:58:49","modified_gmt":"2024-11-21T07:58:49","slug":"%e5%a6%82%e4%bd%95%e9%80%9a%e8%bf%87webman%e6%a1%86%e6%9e%b6%e5%ae%9e%e7%8e%b0%e5%8d%95%e9%a1%b5%e5%ba%94%e7%94%a8%e5%92%8c%e8%b7%af%e7%94%b1%e5%af%bc%e8%88%aa%e5%8a%9f%e8%83%bd%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/24080\/","title":{"rendered":"\u5982\u4f55\u901a\u8fc7Webman\u6846\u67b6\u5b9e\u73b0\u5355\u9875\u5e94\u7528\u548c\u8def\u7531\u5bfc\u822a\u529f\u80fd\uff1f"},"content":{"rendered":"<p>\u5982\u4f55\u901a\u8fc7webman\u6846\u67b6\u5b9e\u73b0\u5355\u9875\u5e94\u7528\u548c\u8def\u7531\u5bfc\u822a\u529f\u80fd\uff1f<\/p>\n<p>Webman \u662f\u4e00\u4e2a\u57fa\u4e8e PHP \u7684\u8f7b\u91cf\u7ea7 Web \u5f00\u53d1\u6846\u67b6\uff0c\u5b83\u63d0\u4f9b\u4e86\u7b80\u5355\u6613\u7528\u7684\u5de5\u5177\u548c\u529f\u80fd\u6765\u5e2e\u52a9\u5f00\u53d1\u8005\u5feb\u901f\u6784\u5efa Web \u5e94\u7528\u7a0b\u5e8f\u3002\u5176\u4e2d\uff0c\u6700\u91cd\u8981\u7684\u529f\u80fd\u4e4b\u4e00\u5c31\u662f\u5355\u9875\u5e94\u7528\u548c\u8def\u7531\u5bfc\u822a\u3002<\/p>\n<p>\u5355\u9875\u5e94\u7528\uff08Single Page Application\uff0cSPA\uff09\u662f\u4e00\u79cd\u4ee5\u7f51\u9875\u5e94\u7528\u7a0b\u5e8f\u65b9\u5f0f\u8fd0\u884c\u7684\u5e94\u7528\uff0c\u5b83\u4e0d\u9700\u8981\u91cd\u65b0\u52a0\u8f7d\u6574\u4e2a\u9875\u9762\u6765\u5b9e\u73b0\u9875\u9762\u5207\u6362\u548c\u6570\u636e\u66f4\u65b0\u3002\u800c\u662f\u901a\u8fc7 AJAX \u8bf7\u6c42\u3001\u524d\u7aef\u8def\u7531\u548c DOM \u64cd\u4f5c\u7b49\u6280\u672f\uff0c\u5b9e\u73b0\u9875\u9762\u4e4b\u95f4\u7684\u5207\u6362\u548c\u6570\u636e\u4ea4\u4e92\u3002<\/p>\n<p>Webman \u63d0\u4f9b\u4e86\u7b80\u5355\u800c\u7075\u6d3b\u7684\u65b9\u5f0f\u6765\u5b9e\u73b0\u5355\u9875\u5e94\u7528\u548c\u8def\u7531\u5bfc\u822a\u529f\u80fd\u3002\u4e0b\u9762\u6211\u4eec\u5c06\u901a\u8fc7\u4e00\u4e2a\u793a\u4f8b\u6765\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 Webman \u5b9e\u73b0\u8fd9\u4e9b\u529f\u80fd\u3002<\/p>\n<p>\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u57fa\u672c\u7684 Webman \u5e94\u7528\u3002<\/p>\n<pre>&lt;?php require 'webman\/webman.php';\n\nuse WebmanApp;\n\nApp::route('\/', function() {\n    \/\/ \u6e32\u67d3\u4e3b\u9875\u6a21\u677f\n    return view('index');\n});\n\nApp::run();<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5728\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a\u6839\u8def\u7531 \/\uff0c\u5e76\u6307\u5b9a\u4e86\u76f8\u5e94\u7684\u5904\u7406\u51fd\u6570\u3002\u5728\u8fd9\u4e2a\u5904\u7406\u51fd\u6570\u4e2d\uff0c\u6211\u4eec\u5c06\u6e32\u67d3\u4e00\u4e2a\u540d\u4e3a index \u7684\u6a21\u677f\u3002<\/p>\n<p>\u4e0b\u4e00\u6b65\uff0c\u6211\u4eec\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u524d\u7aef\u8def\u7531\u3002<\/p>\n<pre>import Vue from 'vue';\nimport VueRouter from 'vue-router';\nimport Home from '.\/components\/Home.vue';\nimport About from '.\/components\/About.vue';\n\nVue.use(VueRouter);\n\nconst router = new VueRouter({\n    mode: 'history',\n    routes: [\n        { path: '\/', component: Home },\n        { path: '\/about', component: About }\n    ]\n});\n\nnew Vue({\n    router\n}).$mount('#app');<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5728\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528 Vue.js \u6765\u521b\u5efa\u4e86\u4e00\u4e2a\u524d\u7aef\u8def\u7531\uff0c\u5e76\u5b9a\u4e49\u4e86\u4e24\u4e2a\u8def\u7531\u89c4\u5219\uff1a\/ \u548c \/about\u3002\u5f53\u7528\u6237\u8bbf\u95ee\u4e0d\u540c\u7684\u8def\u7531\u65f6\uff0c\u5c06\u52a0\u8f7d\u76f8\u5e94\u7684\u7ec4\u4ef6\u3002<\/p>\n<p>\u7136\u540e\uff0c\u6211\u4eec\u9700\u8981\u5728 Webman \u5e94\u7528\u4e2d\u96c6\u6210\u524d\u7aef\u8def\u7531\u3002<\/p>\n<pre>&lt;?php require 'webman\/webman.php';\n\nuse WebmanApp;\nuse IlluminateSupportFacadesView;\n\nApp::route('\/', function() {\n    \/\/ \u6e32\u67d3\u4e3b\u9875\u6a21\u677f\n    return view('index');\n});\n\nApp::route('\/{any}', function() {\n    \/\/ \u6e32\u67d3\u4e3b\u9875\u6a21\u677f\n    return view('index');\n})-&gt;where('any', '.*');\n\nApp::run();<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5728\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u65b0\u589e\u4e86\u4e00\u4e2a\u8def\u7531\u89c4\u5219 \/{any}\uff0c\u5e76\u5c06\u5176\u6307\u5411\u4e3b\u9875\u6a21\u677f\u3002\u8fd9\u6837\uff0c\u65e0\u8bba\u7528\u6237\u8bbf\u95ee\u4efb\u4f55\u8def\u7531\uff0cWebman \u90fd\u5c06\u6e32\u67d3\u4e3b\u9875\u6a21\u677f\u3002<\/p>\n<p>\u6700\u540e\uff0c\u6211\u4eec\u9700\u8981\u5728\u4e3b\u9875\u6a21\u677f\u4e2d\u6dfb\u52a0\u8def\u7531\u89c6\u56fe\u5bb9\u5668\u3002<\/p>\n<pre>\n\n\n    &lt;title&gt;Webman SPA&lt;\/title&gt;&lt;div id=\"app\"&gt;\n        &lt;router-view&gt;&lt;\/router-view&gt;\n&lt;\/div&gt;\n    &lt;script src=\"app.js\"&gt;&lt;\/script&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5728\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u901a\u8fc7  \u6807\u7b7e\u6765\u663e\u793a\u8def\u7531\u89c6\u56fe\u3002\u5f53\u7528\u6237\u8bbf\u95ee\u4e0d\u540c\u7684\u8def\u7531\u65f6\uff0cVue.js \u4f1a\u81ea\u52a8\u6839\u636e\u8def\u7531\u89c4\u5219\u52a0\u8f7d\u76f8\u5e94\u7684\u7ec4\u4ef6\u5e76\u6e32\u67d3\u5728\u8be5\u6807\u7b7e\u4e2d\u3002<\/p>\n<p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u6211\u4eec\u6210\u529f\u5730\u4f7f\u7528 Webman \u6846\u67b6\u5b9e\u73b0\u4e86\u5355\u9875\u5e94\u7528\u548c\u8def\u7531\u5bfc\u822a\u529f\u80fd\u3002\u73b0\u5728\uff0c\u7528\u6237\u53ef\u4ee5\u901a\u8fc7\u70b9\u51fb\u5bfc\u822a\u94fe\u63a5\uff0c\u5b9e\u73b0\u9875\u9762\u5207\u6362\u800c\u65e0\u9700\u91cd\u65b0\u52a0\u8f7d\u6574\u4e2a\u9875\u9762\u3002<\/p>\n<p>\u4ee5\u4e0a\u4ec5\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u4f60\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u6765\u5b9a\u4e49\u5177\u4f53\u7684\u8def\u7531\u89c4\u5219\u548c\u7ec4\u4ef6\u3002\u5e0c\u671b\u672c\u6587\u80fd\u5bf9\u4f60\u5728\u4f7f\u7528 Webman \u6846\u67b6\u5b9e\u73b0\u5355\u9875\u5e94\u7528\u548c\u8def\u7531\u5bfc\u822a\u529f\u80fd\u8fc7\u7a0b\u4e2d\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u901a\u8fc7Webman\u6846\u67b6\u5b9e\u73b0\u5355\u9875\u5e94\u7528\u548c\u8def\u7531\u5bfc\u822a\u529f\u80fd\uff1f\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>\u5982\u4f55\u901a\u8fc7webman\u6846\u67b6\u5b9e\u73b0\u5355\u9875\u5e94\u7528\u548c\u8def\u7531\u5bfc\u822a\u529f\u80fd\uff1f Webman \u662f\u4e00\u4e2a\u57fa\u4e8e PHP \u7684\u8f7b\u91cf\u7ea7 Web \u5f00\u53d1\u6846\u67b6\uff0c\u5b83\u63d0\u4f9b\u4e86\u7b80\u5355\u6613\u7528\u7684\u5de5\u5177\u548c\u529f\u80fd\u6765\u5e2e\u52a9\u5f00\u53d1\u8005\u5feb\u901f\u6784\u5efa Web \u5e94\u7528\u7a0b\u5e8f\u3002\u5176\u4e2d\uff0c\u6700\u91cd\u8981\u7684\u529f\u80fd\u4e4b\u4e00\u5c31\u662f\u5355\u9875\u5e94\u7528\u548c\u8def\u7531\u5bfc\u822a\u3002 \u5355\u9875\u5e94\u7528\uff08Single Page Application\uff0cSPA\uff09\u662f\u4e00\u79cd\u4ee5\u7f51\u9875\u5e94\u7528\u7a0b\u5e8f\u65b9\u5f0f\u8fd0\u884c\u7684\u5e94\u7528\uff0c\u5b83\u4e0d\u9700\u8981\u91cd\u65b0\u52a0\u8f7d\u6574\u4e2a\u9875\u9762\u6765\u5b9e\u73b0\u9875\u9762\u5207\u6362\u548c\u6570\u636e\u66f4\u65b0\u3002\u800c\u662f\u901a\u8fc7 AJAX \u8bf7\u6c42\u3001\u524d\u7aef\u8def\u7531\u548c DOM \u64cd\u4f5c\u7b49\u6280\u672f\uff0c\u5b9e\u73b0\u9875\u9762\u4e4b\u95f4\u7684\u5207\u6362\u548c\u6570\u636e\u4ea4\u4e92\u3002 Webman \u63d0\u4f9b\u4e86\u7b80\u5355\u800c\u7075\u6d3b\u7684\u65b9\u5f0f\u6765\u5b9e\u73b0\u5355\u9875\u5e94\u7528\u548c\u8def\u7531\u5bfc\u822a\u529f\u80fd\u3002\u4e0b\u9762\u6211\u4eec\u5c06\u901a\u8fc7\u4e00\u4e2a\u793a\u4f8b\u6765\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 Webman \u5b9e\u73b0\u8fd9\u4e9b\u529f\u80fd\u3002 \u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u57fa\u672c\u7684 Webman \u5e94\u7528\u3002 &lt;?php require &#8216;webman\/webman.php&#8217;; use WebmanApp; App::route(&#8216;\/&#8217;, function() { \/\/ \u6e32\u67d3\u4e3b\u9875\u6a21\u677f return view(&#8216;index&#8217;); }); App::run(); \u767b\u5f55\u540e\u590d\u5236 \u5728\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a\u6839\u8def\u7531 \/\uff0c\u5e76\u6307\u5b9a\u4e86\u76f8\u5e94\u7684\u5904\u7406\u51fd\u6570\u3002\u5728\u8fd9\u4e2a\u5904\u7406\u51fd\u6570\u4e2d\uff0c\u6211\u4eec\u5c06\u6e32\u67d3\u4e00\u4e2a\u540d\u4e3a index \u7684\u6a21\u677f\u3002 \u4e0b\u4e00\u6b65\uff0c\u6211\u4eec\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u524d\u7aef\u8def\u7531\u3002 import Vue from &#8216;vue&#8217;; import VueRouter from &#8216;vue-router&#8217;; import Home from &#8216;.\/components\/Home.vue&#8217;; [&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-24080","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/24080","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=24080"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/24080\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=24080"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=24080"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=24080"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}