{"id":63,"date":"2021-01-17T19:30:10","date_gmt":"2021-01-17T11:30:10","guid":{"rendered":"http:\/\/gjweb.top\/?p=63"},"modified":"2021-01-17T19:31:05","modified_gmt":"2021-01-17T11:31:05","slug":"%e8%99%9a%e6%8b%9fdom%e4%b8%8edom-dif","status":"publish","type":"post","link":"https:\/\/gjweb.top\/?p=63","title":{"rendered":"\u865a\u62dfDOM\u4e0eDOM dif"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u865a\u62dfDOM\u4f18\u70b9<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>\u51cf\u5c11DOM\u64cd\u4f5c<\/li><li>\u865a\u62dfDOM\u53ef\u4ee5\u591a\u6b21\u64cd\u4f5c\u5408\u5e76\u4e00\u6b21\u64cd\u4f5c(\u4ee3\u7801\u7247\u6bb5)<\/li><li>\u865a\u62dfDOM\u501f\u52a9DOM diff \u53ef\u4ee5\u628a\u591a\u4f59\u7684\u64cd\u4f5c\u7701\u6389<\/li><li>\u8de8\u5e73\u53f0<\/li><li>\u865a\u62dfDOM\u4e0d\u4ec5\u53ef\u4ee5\u7f16\u7a0bDOm,\u8fd8\u53ef\u4ee5\u53d8\u6210\u5c0f\u7a0b\u5e8f\\ios\u5e94\u7528\\\u5b89\u5353\u5e94\u7528,\u56e0\u4e3a\u865a\u62dfDOM\u672c\u8d28\u4e0a\u53ea\u662f\u4e00\u4e2ajs\u5bf9\u8c61<\/li><\/ul>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u865a\u62dfDOM\u662f\u4ec0\u4e48<\/h2>\n\n\n\n<p>\u4e00\u4e2a\u80fd\u4ee3\u8868DOM\u6811\u5bf9\u8c61\u3001\u901a\u5e38\u542b\u6709\u6807\u7b7e\u540d\u3001\u6807\u7b7e\u4e0a\u7684\u5c5e\u6027\u3001\u4e8b\u4ef6\u76d1\u542c\u548c\u5b50\u5143\u7d20\u4eec\uff0c\u4ee5\u53ca\u5176\u4ed6\u5c5e\u6027<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u7f3a\u70b9<\/h2>\n\n\n\n<p>\u9700\u8981\u989d\u5916\u7684\u521b\u5efa\u51fd\u6570\uff0c\u5982createElement \u6216 h \uff0c\u4f46\u53ef\u4ee5\u901a\u8fc7jsx\u7b80\u5316xml<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">DOM diff<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u4ec0\u4e48\u662fDOM diff<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>\u5c31\u662f\u4e00\u4e2a\u51fd\u6570,\u6211\u4eec\u8bda\u631a\u4e3apatch<\/li><li>patch = patch(oldVNode,newVNode)<\/li><li>patches\u5c31\u662f\u8981\u8fd0\u884c\u7684DOM\u64cd\u4f5c<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>\n\/\/ \u903b\u8f91\u793a\u4f8b\r\n&#91;\r\n{type:\"INSERT\",vNode:\u2026},\r\n{type:\"TEXT\",vNode:\u2026},\r\n{type:\"PROPS\",vNode:&#91;]}\r\n]<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>---\n\n### DOM diff \u57fa\u672c\u5b9e\u73b0\u903b\u8f91\n\n-  Tree diff\n  - \u5c06\u5fc3\u5c31\u4e24\u9897\u6811\u9010\u5c42\u5bf9\u6bd4,\u627e\u51fa\u90a3\u4e9b\u8282\u70b9\u9700\u8981\u66f4\u65b0\n  - \u5982\u679c\u8282\u70b9\u662f\u7ec4\u4ef6\u5c31\u770bComponent diff\n  - \u5982\u679c\u8282\u70b9\u662f\u6807\u7b7e\u5c31\u770b Element diff\n- Component diff\n  - \u5982\u679c\u8282\u70b9\u662f\u7ec4\u4ef6,\u5c31\u5148\u770b\u7ec4\u4ef6\u7c7b\u578b\n  - \u7c7b\u578b\u4e0d\u540c\u76f4\u63a5\u66ff\u6362(\u5220\u9664\u65e7\u7684)\n  - \u7c7b\u578b\u76f8\u540c\u53ea\u66f4\u65b0\u5c5e\u6027\n  - \u7136\u540e\u6df1\u5165\u7ec4\u4ef6\u505aTree diff (\u9012\u5f52)\n- Element diff\n  - \u5982\u679c\u8282\u70b9\u662f\u539f\u751f\u6807\u7b7e,\u5219\u770b\u6807\u7b7e\u540d\n  - \u6807\u7b7e\u540d\u4e0d\u540c\u76f4\u63a5\u66ff\u6362,\u76f8\u540c\u5219\u53ea\u66f4\u65b0\u5c5e\u6027\n  - \u7136\u540e\u8fdb\u5165\u6807\u7b7e\u540e\u4ee3\u505aTree diff(\u9012\u5f52)\n\n---\n\n### DOM diff  \u7f3a\u70b9\n\n- \u540c\u7ea7\u8282\u70b9\u5bf9\u6bd4\u5b58\u5728bug\n\n- **\u6c38\u8fdc\u4e0d\u8981\u7528index\u505a\u4e0b\u6807**\n\n- ```vue\n  v-for=\"(item,index) in xxx\" :key=\"item.id\" \/\/ \u63a8\u8350<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">DOM diff \u53d1\u73b0<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>\u60c5\u51b5\u4e00<\/li><li>\u6807\u7b7e\u7c7b\u578b\u6ca1\u53d8,\u53ea\u9700\u8981\u66f4\u65b0div\u5bf9\u5e94\u7684DOM\u7684\u5c5e\u6027<\/li><li>\u5b50\u5143\u7d20\u6ca1\u53d8,\u4e0d\u66f4\u65b0<\/li><li>\u60c5\u51b5\u4e8c<\/li><li>\u5143\u7d20\u6ca1\u53d8,\u4e0d\u66f4\u65b0<\/li><li>\u5b50\u5143\u7d201\u6807\u7b7e\u6ca1\u53d8,\u4f46\u662fchildren\u53d8\u4e86,\u66f4\u65b0dom\u5185\u5bb9<\/li><li>\u8d44\u6e90\u7ec42\u4e0d\u89c1\u4e86,\u5220\u9664\u5bf9\u5e94\u7684DOM<\/li><\/ul>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n","protected":false},"excerpt":{"rendered":"<p>\u865a\u62dfDOM\u4f18\u70b9 \u51cf\u5c11DOM\u64cd\u4f5c \u865a\u62dfDOM\u53ef\u4ee5\u591a\u6b21\u64cd\u4f5c\u5408\u5e76\u4e00\u6b21\u64cd\u4f5c(\u4ee3\u7801\u7247\u6bb5) \u865a\u62dfDOM\u501f\u52a9DOM diff [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-63","post","type-post","status-publish","format-standard","hentry","category-javascript"],"_links":{"self":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/63","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=63"}],"version-history":[{"count":0,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/63\/revisions"}],"wp:attachment":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=63"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=63"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=63"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}