{"id":5983,"date":"2024-04-17T23:28:12","date_gmt":"2024-04-17T15:28:12","guid":{"rendered":"http:\/\/zyg.luchers.cn\/?p=5983"},"modified":"2024-04-17T23:28:12","modified_gmt":"2024-04-17T15:28:12","slug":"%e5%85%ad%e3%80%81%e5%85%b6%e4%bb%96","status":"publish","type":"post","link":"http:\/\/zyg.luchers.cn\/index.php\/2024\/04\/17\/%e5%85%ad%e3%80%81%e5%85%b6%e4%bb%96\/","title":{"rendered":"\u516d\u3001\u5176\u4ed6"},"content":{"rendered":"<h1>\u516d\u3001\u5176\u4ed6<\/h1>\n<h2>1.\u5168\u5c40API\u7684\u8f6c\u79fb<\/h2>\n<ul>\n<li>\n<p>Vue 2.x \u6709\u8bb8\u591a\u5168\u5c40 API \u548c\u914d\u7f6e\u3002<\/p>\n<ul>\n<li>\u4f8b\u5982\uff1a\u6ce8\u518c\u5168\u5c40\u7ec4\u4ef6\u3001\u6ce8\u518c\u5168\u5c40\u6307\u4ee4\u7b49\u3002<\/li>\n<\/ul>\n<pre><code class=\"language-js\">\/\/\u6ce8\u518c\u5168\u5c40\u7ec4\u4ef6\nVue.component('MyButton', {\n  data: () => ({\n    count: 0\n  }),\n  template: '<button @click=\"count++\">Clicked {{ count }} times.<\/button>'\n})\n\n\/\/\u6ce8\u518c\u5168\u5c40\u6307\u4ee4\nVue.directive('focus', {\n  inserted: el => el.focus()\n}<\/code><\/pre>\n<\/li>\n<li>\n<p>Vue3.0\u4e2d\u5bf9\u8fd9\u4e9bAPI\u505a\u51fa\u4e86\u8c03\u6574\uff1a<\/p>\n<ul>\n<li>\u5c06\u5168\u5c40\u7684API\uff0c\u5373\uff1a<code><code>Vue.xxx<\/code>`<code>\u8c03\u6574\u5230\u5e94\u7528\u5b9e\u4f8b\uff08<\/code>`<code>app<\/code><\/code>\uff09\u4e0a<\/li>\n<\/ul>\n<table>\n<thead>\n<tr>\n<th>2.x \u5168\u5c40 API\uff08<code>`<code>Vue<\/code><\/code><code>\uff09 | 3.x \u5b9e\u4f8b API (<\/code>app`)<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Vue.config.xxxx<\/td>\n<td>app.config.xxxx<\/td>\n<\/tr>\n<tr>\n<td>Vue.config.productionTip<\/td>\n<td><strong style=\"color:#DD5145\">\u79fb\u9664<\/strong><\/td>\n<\/tr>\n<tr>\n<td>Vue.component<\/td>\n<td>app.component<\/td>\n<\/tr>\n<tr>\n<td>Vue.directive<\/td>\n<td>app.directive<\/td>\n<\/tr>\n<tr>\n<td>Vue.mixin<\/td>\n<td>app.mixin<\/td>\n<\/tr>\n<tr>\n<td>Vue.use<\/td>\n<td>app.use<\/td>\n<\/tr>\n<tr>\n<td>Vue.prototype<\/td>\n<td>app.config.globalProperties<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<\/ul>\n<h2>2.\u5176\u4ed6\u6539\u53d8<\/h2>\n<ul>\n<li>\n<p>data\u9009\u9879\u5e94\u59cb\u7ec8\u88ab\u58f0\u660e\u4e3a\u4e00\u4e2a\u51fd\u6570\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fc7\u5ea6\u7c7b\u540d\u7684\u66f4\u6539\uff1a<\/p>\n<ul>\n<li>Vue2.x\u5199\u6cd5<\/li>\n<\/ul>\n<pre><code class=\"language-css\">.v-enter,\n.v-leave-to {\n  opacity: 0;\n}\n.v-leave,\n.v-enter-to {\n  opacity: 1;\n}<\/code><\/pre>\n<ul>\n<li>Vue3.x\u5199\u6cd5<\/li>\n<\/ul>\n<pre><code class=\"language-css\">.v-enter-from,\n.v-leave-to {\n  opacity: 0;\n}\n\n.v-leave-from,\n.v-enter-to {\n  opacity: 1;\n}<\/code><\/pre>\n<\/li>\n<li>\n<p><strong style=\"color:#DD5145\">\u79fb\u9664<\/strong>keyCode\u4f5c\u4e3a v-on \u7684\u4fee\u9970\u7b26\uff0c\u540c\u65f6\u4e5f\u4e0d\u518d\u652f\u6301<code><code>config.keyCodes<\/code><\/code><\/p>\n<\/li>\n<li>\n<p><strong style=\"color:#DD5145\">\u79fb\u9664<\/strong><code><code>v-on.native<\/code><\/code>\u4fee\u9970\u7b26<\/p>\n<ul>\n<li>\u7236\u7ec4\u4ef6\u4e2d\u7ed1\u5b9a\u4e8b\u4ef6<\/li>\n<\/ul>\n<pre><code class=\"language-vue\"><my-component\n  v-on:close=\"handleComponentEvent\"\n  v-on:click=\"handleNativeClickEvent\"\n\/><\/code><\/pre>\n<ul>\n<li>\u5b50\u7ec4\u4ef6\u4e2d\u58f0\u660e\u81ea\u5b9a\u4e49\u4e8b\u4ef6<\/li>\n<\/ul>\n<pre><code class=\"language-vue\"><script>\n  export default {\n    emits: ['close']\n  }\n<\/script><\/code><\/pre>\n<\/li>\n<li>\n<p><strong style=\"color:#DD5145\">\u79fb\u9664<\/strong>\u8fc7\u6ee4\u5668\uff08filter\uff09<\/p>\n<blockquote>\n<p>\u8fc7\u6ee4\u5668\u867d\u7136\u8fd9\u770b\u8d77\u6765\u5f88\u65b9\u4fbf\uff0c\u4f46\u5b83\u9700\u8981\u4e00\u4e2a\u81ea\u5b9a\u4e49\u8bed\u6cd5\uff0c\u6253\u7834\u5927\u62ec\u53f7\u5185\u8868\u8fbe\u5f0f\u662f \u201c\u53ea\u662f JavaScript\u201d \u7684\u5047\u8bbe\uff0c\u8fd9\u4e0d\u4ec5\u6709\u5b66\u4e60\u6210\u672c\uff0c\u800c\u4e14\u6709\u5b9e\u73b0\u6210\u672c\uff01\u5efa\u8bae\u7528\u65b9\u6cd5\u8c03\u7528\u6216\u8ba1\u7b97\u5c5e\u6027\u53bb\u66ff\u6362\u8fc7\u6ee4\u5668\u3002<\/p>\n<\/blockquote>\n<\/li>\n<li>\n<p>......<\/p>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u516d\u3001\u5176\u4ed6 1.\u5168\u5c40API\u7684\u8f6c\u79fb Vue 2.x \u6709\u8bb8\u591a\u5168\u5c40 API \u548c\u914d\u7f6e\u3002 \u4f8b\u5982\uff1a\u6ce8\u518c\u5168\u5c40\u7ec4\u4ef6\u3001\u6ce8\u518c\u5168\u5c40\u6307\u4ee4 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[61],"tags":[],"class_list":["post-5983","post","type-post","status-publish","format-standard","hentry","category-vue3"],"_links":{"self":[{"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/posts\/5983","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/comments?post=5983"}],"version-history":[{"count":1,"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/posts\/5983\/revisions"}],"predecessor-version":[{"id":5984,"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/posts\/5983\/revisions\/5984"}],"wp:attachment":[{"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/media?parent=5983"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/categories?post=5983"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/zyg.luchers.cn\/index.php\/wp-json\/wp\/v2\/tags?post=5983"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}