{"id":98,"date":"2021-01-18T20:17:30","date_gmt":"2021-01-18T12:17:30","guid":{"rendered":"http:\/\/gjweb.top\/?p=98"},"modified":"2021-01-18T20:17:31","modified_gmt":"2021-01-18T12:17:31","slug":"%e7%bb%84%e4%bb%b6%e7%9a%84%e4%bd%bf%e7%94%a8","status":"publish","type":"post","link":"https:\/\/gjweb.top\/?p=98","title":{"rendered":"\u7ec4\u4ef6\u7684\u4f7f\u7528"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u521b\u5efa\u7ec4\u4ef6<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u521b\u5efa\u7ec4\u4ef6<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>Vue.component(\"\u7ec4\u4ef6\u540d\u79f0\",{template:\"&lt;h3&gt;\u6a21\u677f&lt;\/h3&gt;\"})<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u7ec4\u4ef6 \u7684\u4f7f\u7528<\/h3>\n\n\n\n<p>\u200b \u7ec4\u4ef6\u7684\u4f7f\u7528\u5c31\u50cfhtml\u6807\u7b7e\u4e00\u6837<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;\u7ec4\u4ef6\u540d\u79f0&gt;&lt;\/\u7ec4\u4ef6\u540d\u79f0&gt;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>\u6ce8\u610f<\/li><li>\u5982\u679c\u4e00\u4e2a\u7ec4\u4ef6\u4e2d\u6e32\u67d3\u591a\u4e2a\u5143\u7d20,\u5c06\u591a\u4e2a\u5143\u7d20\u653e\u5230\u4e00\u4e2a\u8ddf\u6807\u7b7e,\u5426\u5219\u4f1a\u62a5\u9519<\/li><\/ul>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u521b\u5efa\u7b26\u5408\u7ec4\u5efa<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>\u5b9a\u4e49<\/li><li>\u53ea\u7528\u4e00\u4e2a\u7ec4\u4ef6\u8c03\u7528\u4e86\u5176\u4ed6\u7684\u7ec4\u4ef6<\/li><li>\u521b\u5efa<\/li><li>\u901a\u521b\u5efa\u7ec4\u4ef6\u4e00\u6837<\/li><\/ul>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u7ec4\u4ef6\u7684\u751f\u547d\u5468\u671f<\/h2>\n\n\n\n<p>\u5206\u522b\u4e3a\u56db\u4e2a\u9636\u6bb5,\u6bcf\u4e2a\u9636\u6bb5\u90fd\u6709\u5bf9\u5e94\u7684\u51fd\u6570<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>create \u521d\u59cb\u5316\u64cd\u4f5c<\/li><li>create<\/li><li>beforCreate<\/li><li>mount \u6302\u8f7dDOM<\/li><li>mount<\/li><li>beforMount<\/li><li>update \u6570\u636e\u66f4\u65b0 \u64cd\u4f5c\u6216\u903b\u8f91\u5224\u65ad<\/li><li>uodate<\/li><li>beforUpdate<\/li><li>destroy \u6e05\u7406\u5de5\u4f5c<\/li><li>destroy<\/li><li>beforDestroy<\/li><\/ul>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u76d1\u542c\u5c5e\u6027<\/h2>\n\n\n\n<p>watch<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u7ec4\u4ef6\u4e4b\u95f4\u7684\u901a\u4fe1<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u7236\u5b50\u7ec4\u4ef6\u901a\u4fe1<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ 1. \u7236\u7ec4\u4ef6\u5728\u8c03\u7528\u5b50\u7ec4\u4ef6\u4f20\u503c\n&lt;child myValue=\"123\"&gt;&lt;child&gt;\n\/\/ 2. \u5b50\u7ec4\u4ef6\u4e2d\u83b7\u5f97\u7236\u7ec4\u4ef6\nvue.component(\"child\",{\n    props:&#91;'myValue'] \/\/ \u751f\u547d\u7236\u7ec4\u4ef6\u4f20\u9012\u53c2\u6570\n    trmplate\n})<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u5b50\u7236\u7ec4\u4ef6\u4e4b\u95f4\u901a\u4fe1<\/h3>\n\n\n\n<p>\u901a\u8fc7\u5b9e\u8df5\u7684\u65b9\u5f0f\u6765\u5b8c\u6210\u6570\u636e\u7684\u4f20\u8f93<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ 1.\u5728\u7236\u7ec4\u4ef6\u4e2d\u5b9a\u4e00\u4e2a\u65b9\u6cd5,\u7528\u4e8e\u63a5\u6536\u5b50\u7ec4\u4ef6\u901a\u8fc7\u5b9e\u8df5\u53d1\u9001\u7684\u6570\u636e\nmethods:{\n    getdata(msg){\n        \/\/ msg\u5c31\u662f\u5b50\u7ec4\u4ef6\u95ef\u8fc7\u7684\u6570\u636e\n    }\n}\n\/\/ 2. \u7236\u7ec4\u4ef6\u6a21\u677f\u7ed1\u5b9a\u65f6\u95f4\u5904\u7406\u51fd\u6570\n&lt;child @\u81ea\u5b9a\u4e49\u4e8b\u4ef6=\"\u65b9\u6cd5\u540d\"&gt;&lt;\/child&gt;\n\/\/ 3. \u5728\u5b50\u7ec4\u4ef6\u4e2d\u89e6\u53d1\u4e8b\u4ef6,\u5e76\u4f20\u9012\u6570\u636e\nthis.$emit(\"\u89e6\u53d1\u4e8b\u4ef6\u540d\",\u4f20\u9012\u6570\u636e)<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u7ec4\u4ef6\u4e4b\u95f4\u901a\u4fe1($parent;$refs)<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u7236\u7ec4\u4ef6\u83b7\u5f97\u5b50\u7ec4\u4ef6\u7684\u6570\u636e\n\/\/ 1. \u5728\u8c03\u7528\u5b50\u7ec4\u4ef6,\u6307\u5b9a\u5c5e\u6027ref\n&lt;child ref=\"xxx\"&gt;&lt;\/child&gt;\n\/\/ 2.\u6839\u636e\u6307\u5b9a\u540d\u79f0,\u627e\u5230\u5b50\u7ec4\u4ef6\u5b9e\u4f8b\u5bf9\u8c61\nthis.$refs.xxx\n\/\/ \u5b50\u7ec4\u4ef6\u83b7\u5f97\u7236\u7ec4\u4ef6\u7684\u6570\u636e\nthis.$parent.\u7236\u7ec4\u4ef6\u7684\u5c5e\u6027\u540d\n\/\/ \u6ce8\u610f: \u53ea\u652f\u6301\u5728data\u91cc\u7684\u6570\u636e<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u4e8b\u4ef6\u603b\u7ebf\u4f20\u503c<\/h3>\n\n\n\n<p>\u501f\u52a9\u4e8e\u4e00\u4e2a\u516c\u5171Vue\u5b9e\u4f8b\u5bf9\u8c61,\u4e0d\u540c\u7684\u7ec4\u4ef6\u53ef\u4ee5\u901a\u8fc7\u8be5\u5bf9\u8c61\u5b8c\u6210\u4e8b\u4ef6\u7ed1\u5b9a\u89e6\u53d1<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var bus = new Vue();\nbus.$on() \/\/ \u7ed1\u5b9a\u4e8b\u4ef6\nbus.$emit() \/\/ \u53d1\u9001\u4e8b\u4ef6\n\/\/ \u793a\u4f8b\n\/\/ \u63a5\u6536\u65b9\n    bus,$on(\"\u51fd\u6570\u540d\",function(msg){\n        \/\/ msg \u63a5\u6536\u7684\u6570\u636e\n    })\n\/\/ \u53d1\u9001\u65b9\n    bus.$on(\"\u51fd\u6570\u540d\",\"\u4f20\u9012\u7684\u53c2\u6570\")<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u521b\u5efa\u7ec4\u4ef6 \u521b\u5efa\u7ec4\u4ef6 \u7ec4\u4ef6 \u7684\u4f7f\u7528 \u200b \u7ec4\u4ef6\u7684\u4f7f\u7528\u5c31\u50cfhtml\u6807\u7b7e\u4e00\u6837 \u6ce8\u610f \u5982\u679c\u4e00\u4e2a\u7ec4\u4ef6\u4e2d\u6e32\u67d3\u591a\u4e2a\u5143\u7d20,\u5c06\u591a\u4e2a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-98","post","type-post","status-publish","format-standard","hentry","category-vue"],"_links":{"self":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/98","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=98"}],"version-history":[{"count":0,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/98\/revisions"}],"wp:attachment":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=98"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=98"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=98"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}