{"id":274489,"date":"2024-05-16T14:04:48","date_gmt":"2024-05-16T06:04:48","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/274489.html"},"modified":"2024-05-16T14:05:03","modified_gmt":"2024-05-16T06:05:03","slug":"vue%e9%a1%b9%e7%9b%ae%e7%9a%84%e7%bb%84%e4%bb%b6%e6%80%8e%e4%b9%88%e5%b0%81%e8%a3%85","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/274489.html","title":{"rendered":"vue\u9879\u76ee\u7684\u7ec4\u4ef6\u600e\u4e48\u5c01\u88c5"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24195855\/ce1ca2c9-1d83-46fc-845c-4f5c4ad2305b.webp\" alt=\"vue\u9879\u76ee\u7684\u7ec4\u4ef6\u600e\u4e48\u5c01\u88c5\" \/><\/p>\n<p><p>\u5c01\u88c5Vue\u9879\u76ee\u4e2d\u7684\u7ec4\u4ef6\u4e3b\u8981\u6d89\u53ca\u4ee5\u4e0b\u51e0\u4e2a\u5173\u952e\u6b65\u9aa4\uff1a<strong>\u5b9a\u4e49\u7ec4\u4ef6\u7684\u76ee\u7684\u548c\u8fb9\u754c\u3001\u8bbe\u8ba1\u7ec4\u4ef6\u7684API\u3001\u5b9e\u73b0\u6570\u636e\u7ed1\u5b9a\u548c\u4e8b\u4ef6\u3001\u8003\u8651\u7ec4\u4ef6\u7684\u53ef\u590d\u7528\u6027\u548c\u53ef\u7ef4\u62a4\u6027\u3001\u7f16\u5199\u6587\u6863\u548c\u793a\u4f8b<\/strong>\u3002\u5c01\u88c5\u7ec4\u4ef6\u7684\u8fc7\u7a0b\u4e2d\uff0c<strong>\u8bbe\u8ba1\u7ec4\u4ef6\u7684API<\/strong> \u662f\u81f3\u5173\u91cd\u8981\u7684\u4e00\u6b65\uff0c\u56e0\u4e3a\u4e00\u4e2a\u6e05\u6670\u3001\u7b80\u6d01\u7684API\u4e0d\u4ec5\u80fd\u63d0\u9ad8\u7ec4\u4ef6\u7684\u6613\u7528\u6027\uff0c\u8fd8\u80fd\u964d\u4f4e\u5b66\u4e60\u6210\u672c\u548c\u4f7f\u7528\u6210\u672c\u3002\u8bbe\u8ba1API\u65f6\uff0c\u9700\u8981\u8003\u8651\u5230\u7ec4\u4ef6\u7684\u5c5e\u6027\uff08props\uff09\u3001\u4e8b\u4ef6\uff08events\uff09\u3001\u63d2\u69fd\uff08slots\uff09\u7b49\uff0c\u8fd9\u4e9b\u90fd\u662f\u7ec4\u4ef6\u5bf9\u5916\u4ea4\u4e92\u7684\u63a5\u53e3\u3002\u540c\u65f6\uff0c\u826f\u597d\u7684API\u8bbe\u8ba1\u8fd8\u8981\u80fd\u591f\u4f7f\u5f97\u7ec4\u4ef6\u5728\u4e0d\u540c\u573a\u666f\u4e0b\u7684\u914d\u7f6e\u5c3d\u53ef\u80fd\u7075\u6d3b\uff0c\u6ee1\u8db3\u4e0d\u540c\u7528\u6237\u7684\u9700\u6c42\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u5b9a\u4e49\u7ec4\u4ef6\u7684\u76ee\u7684\u548c\u8fb9\u754c<\/h3>\n<\/p>\n<p><p>\u5728\u5f00\u59cb\u5c01\u88c5\u7ec4\u4ef6\u4e4b\u524d\uff0c\u9996\u5148\u660e\u786e\u7ec4\u4ef6\u7684\u529f\u80fd\u8303\u56f4\u548c\u76ee\u6807\u662f\u975e\u5e38\u5fc5\u8981\u7684\u3002\u4e00\u4e2a\u597d\u7684\u7ec4\u4ef6\u5e94\u8be5\u662f\u72ec\u7acb\u4e14\u5177\u6709\u5355\u4e00\u804c\u8d23\uff0c\u8fd9\u6837\u4e0d\u4ec5\u4fbf\u4e8e\u7ec4\u4ef6\u7684\u91cd\u7528\uff0c\u4e5f\u4f7f\u5f97\u7ec4\u4ef6\u66f4\u5bb9\u6613\u7ef4\u62a4\u3002<\/p>\n<\/p>\n<ul>\n<li>\u786e\u5b9a\u7ec4\u4ef6\u9700\u8981\u5b8c\u6210\u4ec0\u4e48\u529f\u80fd\u3001\u89e3\u51b3\u4ec0\u4e48\u95ee\u9898\u3002\u4f8b\u5982\uff0c\u662f\u5426\u662f\u4e3a\u4e86\u8f93\u5165\u6570\u636e\u3001\u663e\u793a\u6570\u636e\u3001\u8fd8\u662f\u5904\u7406\u6570\u636e\u6d41\u7b49\u3002<\/li>\n<li>\u660e\u786e\u7ec4\u4ef6\u7684\u8fb9\u754c\uff0c\u7406\u89e3\u54ea\u4e9b\u529f\u80fd\u5c5e\u4e8e\u7ec4\u4ef6\u5185\u90e8\u5904\u7406\uff0c\u54ea\u4e9b\u529f\u80fd\u5e94\u8be5\u7559\u7ed9\u7ec4\u4ef6\u4f7f\u7528\u8005\u53bb\u5b9e\u73b0\u3002\u8fd9\u6709\u52a9\u4e8e\u51cf\u5c11\u7ec4\u4ef6\u7684\u590d\u6742\u5ea6\uff0c\u4f7f\u5176\u66f4\u4e13\u6ce8\u4e8e\u6267\u884c\u4e00\u4e2a\u7279\u5b9a\u7684\u4efb\u52a1\u3002<\/li>\n<\/ul>\n<p><h3>\u4e8c\u3001\u8bbe\u8ba1\u7ec4\u4ef6\u7684API<\/h3>\n<\/p>\n<p><p>\u8bbe\u8ba1\u7ec4\u4ef6API\u7684\u76ee\u6807\u662f\u4fdd\u8bc1\u7ec4\u4ef6\u7684\u7075\u6d3b\u6027\u548c\u53ef\u7528\u6027\u3002\u7ec4\u4ef6\u7684API\u5305\u62ec\u5c5e\u6027\uff08props\uff09\u3001\u4e8b\u4ef6\uff08events\uff09\u548c\u63d2\u69fd\uff08slots\uff09\u7b49\u3002<\/p>\n<\/p>\n<ul>\n<li><strong>\u5c5e\u6027\uff08props\uff09<\/strong>\uff1a\u8bbe\u8ba1\u65f6\u9700\u8981\u8003\u8651\u54ea\u4e9b\u662f\u5fc5\u9700\u7684\uff0c\u54ea\u4e9b\u662f\u53ef\u9009\u7684\u3002\u540c\u65f6\uff0c\u5bf9\u4e8e\u6bcf\u4e2aprop\uff0c\u90fd\u9700\u8981\u5b9a\u4e49\u5176\u7c7b\u578b\u3001\u9ed8\u8ba4\u503c\uff08\u5982\u679c\u6709\u7684\u8bdd\uff09\u4ee5\u53ca\u662f\u5426\u5fc5\u987b\u3002<\/li>\n<li><strong>\u4e8b\u4ef6\uff08events\uff09<\/strong>\uff1a\u7ec4\u4ef6\u53ef\u80fd\u4f1a\u89e6\u53d1\u7684\u4e8b\u4ef6\uff0c\u4ee5\u53ca\u4e8b\u4ef6\u7684\u547d\u540d\u89c4\u8303\uff0c\u9700\u8ba9\u4f7f\u7528\u8005\u80fd\u591f\u5bb9\u6613\u7406\u89e3\u548c\u4f7f\u7528\u3002<\/li>\n<li><strong>\u63d2\u69fd\uff08slots\uff09<\/strong>\uff1a\u5bf9\u4e8e\u67d0\u4e9b\u9700\u8981\u81ea\u5b9a\u4e49\u5185\u5bb9\u7684\u90e8\u5206\uff0c\u901a\u8fc7\u63d2\u69fd\u8ba9\u4f7f\u7528\u8005\u63d2\u5165\u81ea\u5df1\u7684\u5185\u5bb9\u6216\u7ec4\u4ef6\uff0c\u589e\u52a0\u7ec4\u4ef6\u7684\u7075\u6d3b\u6027\u3002<\/li>\n<\/ul>\n<p><h3>\u4e09\u3001\u5b9e\u73b0\u6570\u636e\u7ed1\u5b9a\u548c\u4e8b\u4ef6<\/h3>\n<\/p>\n<p><p>\u6570\u636e\u7ed1\u5b9a\u548c\u4e8b\u4ef6\u5904\u7406\u662fVue\u7ec4\u4ef6\u4e2d\u6700\u6838\u5fc3\u7684\u6982\u5ff5\u4e4b\u4e00\u3002<\/p>\n<\/p>\n<ul>\n<li><strong>\u6570\u636e\u7ed1\u5b9a<\/strong>\uff1a\u786e\u4fdd\u7ec4\u4ef6\u7684\u6570\u636e\u80fd\u591f\u6b63\u786e\u54cd\u5e94\u5916\u90e8\u4f20\u5165\u7684\u53d8\u5316\uff0c\u4ee5\u53ca\u5185\u90e8\u72b6\u6001\u7684\u53d8\u5316\u80fd\u591f\u6b63\u786e\u53cd\u6620\u5230\u89c6\u56fe\u4e0a\u3002<\/li>\n<li><strong>\u4e8b\u4ef6\u5904\u7406<\/strong>\uff1a\u7ec4\u4ef6\u9700\u8981\u5904\u7406\u7528\u6237\u7684\u8f93\u5165\u548c\u4ea4\u4e92\uff0c\u5408\u7406\u5730\u8bbe\u8ba1\u4e8b\u4ef6\u5904\u7406\u51fd\u6570\u548c\u4e8b\u4ef6\u4f20\u9012\u673a\u5236\uff0c\u4f7f\u5f97\u7ec4\u4ef6\u7684\u4f7f\u7528\u8005\u80fd\u591f\u65b9\u4fbf\u5730\u5bf9\u4e8b\u4ef6\u8fdb\u884c\u5904\u7406\u3002<\/li>\n<\/ul>\n<p><h3>\u56db\u3001\u8003\u8651\u7ec4\u4ef6\u7684\u53ef\u590d\u7528\u6027\u548c\u53ef\u7ef4\u62a4\u6027<\/h3>\n<\/p>\n<p><p>\u5c01\u88c5\u7ec4\u4ef6\u65f6\uff0c\u9700\u8981\u8003\u8651\u5230\u7ec4\u4ef6\u7684\u53ef\u590d\u7528\u6027\u548c\u53ef\u7ef4\u62a4\u6027\u3002<\/p>\n<\/p>\n<ul>\n<li><strong>\u53ef\u590d\u7528\u6027<\/strong>\uff1a\u5c3d\u53ef\u80fd\u5730\u4f7f\u7ec4\u4ef6\u901a\u7528\u5316\uff0c\u901a\u8fc7\u914d\u7f6e\u9879\u8ba9\u7ec4\u4ef6\u9002\u7528\u4e8e\u4e0d\u540c\u7684\u573a\u666f\u3002<\/li>\n<li><strong>\u53ef\u7ef4\u62a4\u6027<\/strong>\uff1a\u9075\u5faa\u4e00\u5b9a\u7684\u4ee3\u7801\u89c4\u8303\uff0c\u7f16\u5199\u53ef\u8bfb\u6027\u5f3a\u3001\u7ed3\u6784\u6e05\u6670\u7684\u4ee3\u7801\uff0c\u540c\u65f6\u4e5f\u4e0d\u8981\u5fd8\u8bb0\u7f16\u5199\u7ec4\u4ef6\u7684\u6d4b\u8bd5\u7528\u4f8b\u3002<\/li>\n<\/ul>\n<p><h3>\u4e94\u3001\u7f16\u5199\u6587\u6863\u548c\u793a\u4f8b<\/h3>\n<\/p>\n<p><p>\u4e00\u4e2a\u6ca1\u6709\u6587\u6863\u548c\u793a\u4f8b\u7684\u7ec4\u4ef6\uff0c\u5c31\u50cf\u662f\u4e00\u4e2a\u6ca1\u6709\u8bf4\u660e\u4e66\u7684\u9ad8\u7aef\u4ea7\u54c1\u3002\u4e0d\u8bba\u7ec4\u4ef6\u8bbe\u8ba1\u5f97\u591a\u4e48\u5b8c\u7f8e\uff0c\u7f3a\u4e4f\u8db3\u591f\u7684\u6587\u6863\u652f\u6301\u90fd\u4f1a\u5927\u5927\u964d\u4f4e\u5176\u4f7f\u7528\u7387\u3002<\/p>\n<\/p>\n<ul>\n<li><strong>\u6587\u6863<\/strong>\uff1a\u5305\u542b\u7ec4\u4ef6\u7684\u5b89\u88c5\u65b9\u6cd5\u3001API\u8bf4\u660e\u3001\u5e38\u89c1\u95ee\u9898\u89e3\u7b54\u7b49\u3002<\/li>\n<li><strong>\u793a\u4f8b<\/strong>\uff1a\u63d0\u4f9b\u4e00\u4e9b\u5e38\u89c1\u7528\u6cd5\u7684\u793a\u4f8b\u4ee3\u7801\uff0c\u5e2e\u52a9\u7528\u6237\u5feb\u901f\u7406\u89e3\u548c\u4f7f\u7528\u7ec4\u4ef6\u3002<\/li>\n<\/ul>\n<p><p>\u5c01\u88c5Vue\u7ec4\u4ef6\u662f\u4e00\u4e2a\u7cfb\u7edf\u4e14\u7ec6\u81f4\u7684\u8fc7\u7a0b\uff0c\u9700\u8981\u5f00\u53d1\u8005\u5728\u8bbe\u8ba1\u3001\u5b9e\u73b0\u548c\u4f18\u5316\u4e0a\u4e0d\u65ad\u601d\u8003\u548c\u8fed\u4ee3\u3002\u901a\u8fc7\u9075\u5faa\u4e0a\u8ff0\u6b65\u9aa4\uff0c\u53ef\u4ee5\u9ad8\u6548\u5730\u5f00\u53d1\u51fa\u6613\u4e8e\u7ef4\u62a4\u3001\u9ad8\u5ea6\u53ef\u7528\u7684Vue\u7ec4\u4ef6\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>1. \u5728Vue\u9879\u76ee\u4e2d\uff0c\u5982\u4f55\u5c01\u88c5\u53ef\u590d\u7528\u7684\u7ec4\u4ef6\uff1f<\/strong><br \/>\n\u5f53\u9700\u8981\u5728Vue\u9879\u76ee\u4e2d\u5c01\u88c5\u53ef\u590d\u7528\u7684\u7ec4\u4ef6\u65f6\uff0c\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\u64cd\u4f5c\uff1a<\/p>\n<ul>\n<li>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Vue\u7ec4\u4ef6\u6587\u4ef6\uff0c\u4ee5.vue\u4e3a\u540e\u7f00\uff0c\u4f8b\u5982ExampleComponent.vue\u3002<\/li>\n<li>\u5728\u7ec4\u4ef6\u6587\u4ef6\u4e2d\uff0c\u4f7f\u7528template\u6807\u7b7e\u5b9a\u4e49\u7ec4\u4ef6\u7684HTML\u7ed3\u6784\uff0c\u53ef\u4ee5\u6dfb\u52a0props\u5c5e\u6027\u63a5\u6536\u6765\u81ea\u7236\u7ec4\u4ef6\u7684\u6570\u636e\u3002<\/li>\n<li>\u4f7f\u7528script\u6807\u7b7e\u5bfc\u51fa\u7ec4\u4ef6\uff0c\u53ef\u4ee5\u5728\u5176\u4e2d\u5b9a\u4e49\u9700\u8981\u7684data\u3001methods\u3001computed\u7b49\u3002<\/li>\n<li>\u5982\u679c\u9700\u8981\u6837\u5f0f\uff0c\u53ef\u4ee5\u901a\u8fc7style\u6807\u7b7e\u6dfb\u52a0\u7ec4\u4ef6\u7684CSS\u6837\u5f0f\u3002<\/li>\n<\/ul>\n<p><strong>2. \u5982\u4f55\u5728Vue\u7ec4\u4ef6\u4e2d\u4f7f\u7528\u5c01\u88c5\u7684\u7ec4\u4ef6\uff1f<\/strong><br \/>\n\u8981\u5728Vue\u7ec4\u4ef6\u4e2d\u4f7f\u7528\u5df2\u5c01\u88c5\u7684\u7ec4\u4ef6\uff0c\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\u64cd\u4f5c\uff1a<\/p>\n<ul>\n<li>\u5728\u9700\u8981\u4f7f\u7528\u7ec4\u4ef6\u7684\u9875\u9762\u4e2d\uff0c\u5f15\u5165\u5c01\u88c5\u597d\u7684\u7ec4\u4ef6\uff0c\u4f8b\u5982import ExampleComponent from &#039;path\/to\/ExampleComponent.vue&#039;\u3002<\/li>\n<li>\u5728Vue\u7ec4\u4ef6\u4e2d\uff0c\u4f7f\u7528components\u5c5e\u6027\u6ce8\u518c\u7ec4\u4ef6\uff0c\u4f8b\u5982components: { ExampleComponent }\u3002<\/li>\n<li>\u5728Vue\u7ec4\u4ef6\u7684template\u4e2d\uff0c\u901a\u8fc7\u6807\u7b7e\u7684\u65b9\u5f0f\u4f7f\u7528\u521a\u624d\u6ce8\u518c\u7684\u7ec4\u4ef6\uff0c\u4f8b\u5982\u3002<\/li>\n<\/ul>\n<p><strong>3. \u5982\u4f55\u5c01\u88c5\u5177\u6709\u4ea4\u4e92\u80fd\u529b\u7684Vue\u7ec4\u4ef6\uff1f<\/strong><br \/>\n\u8981\u5c01\u88c5\u5177\u6709\u4ea4\u4e92\u80fd\u529b\u7684Vue\u7ec4\u4ef6\uff0c\u53ef\u4ee5\u91c7\u53d6\u4ee5\u4e0b\u65b9\u6cd5\uff1a<\/p>\n<ul>\n<li>\u5728\u7ec4\u4ef6\u4e2d\u6dfb\u52a0data\u5c5e\u6027\uff0c\u7528\u4e8e\u5b58\u50a8\u7ec4\u4ef6\u7684\u5185\u90e8\u72b6\u6001\u3002<\/li>\n<li>\u4f7f\u7528methods\u5c5e\u6027\u5b9a\u4e49\u7ec4\u4ef6\u7684\u65b9\u6cd5\uff0c\u7528\u4e8e\u5904\u7406\u7ec4\u4ef6\u7684\u4ea4\u4e92\u903b\u8f91\u3002<\/li>\n<li>\u5728template\u4e2d\uff0c\u901a\u8fc7\u7ed1\u5b9a\u4e8b\u4ef6\u548c\u6570\u636e\u5c5e\u6027\u7684\u65b9\u5f0f\u4e0e\u7528\u6237\u8fdb\u884c\u4ea4\u4e92\u3002<\/li>\n<li>\u5982\u679c\u9700\u8981\u4e0e\u7236\u7ec4\u4ef6\u901a\u4fe1\uff0c\u53ef\u4ee5\u901a\u8fc7props\u5c5e\u6027\u63a5\u6536\u7236\u7ec4\u4ef6\u4f20\u9012\u7684\u6570\u636e\uff0c\u5e76\u901a\u8fc7$emit\u4e8b\u4ef6\u5411\u7236\u7ec4\u4ef6\u53d1\u9001\u6d88\u606f\u3002<\/li>\n<li>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u7ec4\u4ef6\u7684\u4ea4\u4e92\u903b\u8f91\u5e94\u5c3d\u91cf\u4fdd\u6301\u7b80\u5355\u548c\u53ef\u9884\u6d4b\u6027\uff0c\u907f\u514d\u8fc7\u4e8e\u81c3\u80bf\u7684\u4ee3\u7801\uff0c\u4ee5\u53ca\u6570\u636e\u548c\u65b9\u6cd5\u7684\u8026\u5408\u5ea6\u8fc7\u9ad8\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"\u5c01\u88c5Vue\u9879\u76ee\u4e2d\u7684\u7ec4\u4ef6\u4e3b\u8981\u6d89\u53ca\u4ee5\u4e0b\u51e0\u4e2a\u5173\u952e\u6b65\u9aa4\uff1a\u5b9a\u4e49\u7ec4\u4ef6\u7684\u76ee\u7684\u548c\u8fb9\u754c\u3001\u8bbe\u8ba1\u7ec4\u4ef6\u7684API\u3001\u5b9e\u73b0\u6570\u636e\u7ed1\u5b9a\u548c\u4e8b\u4ef6\u3001\u8003 [&hellip;]","protected":false},"author":3,"featured_media":274509,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/274489"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=274489"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/274489\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/274509"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=274489"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=274489"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=274489"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}