[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"$KiqIp5Qu8t":3,"vue-tips-\u002Fvue-tips\u002Fuse-teleport-to-render-a-component-in-a-different-place":52,"blogToc-\u002Fvue-tips\u002Fuse-teleport-to-render-a-component-in-a-different-place":193,"vue-tips-surrounding-\u002Fvue-tips\u002Fuse-teleport-to-render-a-component-in-a-different-place":273},{"id":4,"extension":5,"items":6,"meta":49,"stem":50,"__hash__":51},"menu\u002Fmenu.json","json",[7,12,16,20,24,28,32,36,41,45],{"i18nId":8,"to":9,"ariaLabel":10,"mainNavigation":11},"components.menu.home","\u002F","Home",true,{"i18nId":13,"to":14,"ariaLabel":15,"mainNavigation":11},"components.menu.about","\u002Fhire-me","About",{"i18nId":17,"to":18,"ariaLabel":19,"mainNavigation":11},"components.menu.testimonials","\u002Ftestimonials","Testimonials",{"i18nId":21,"to":22,"ariaLabel":23},"components.menu.contact","\u002Fcontact","Contact",{"i18nId":25,"to":26,"ariaLabel":27,"mainNavigation":11},"components.menu.blog","\u002Fblog","Blog",{"i18nId":29,"to":30,"ariaLabel":31,"mainNavigation":11},"components.menu.tips","\u002Fvue-tips","Vue Tips",{"i18nId":33,"to":34,"ariaLabel":35,"mainNavigation":11},"components.menu.projects","\u002Fprojects","Projects",{"i18nId":37,"to":38,"ariaLabel":39,"mainNavigation":40},"components.menu.stats","\u002Fstats","stats",false,{"i18nId":42,"to":43,"ariaLabel":44,"mainNavigation":40},"components.menu.businessCard","\u002Fbusiness-card","Business Card",{"i18nId":46,"to":47,"ariaLabel":48,"mainNavigation":40},"components.menu.publications","\u002Fpublications","Publications",{},"menu","njLT1QoRt2Dv8QWoVmH8xdTAiDywSj0bxBQdmoyWUE0",{"id":53,"title":54,"body":55,"categories":176,"cover":177,"date":178,"description":179,"extension":180,"lastUpdated":181,"meta":182,"navigation":11,"ogImage":181,"path":183,"readingTime":184,"robots":181,"schemaOrg":181,"seo":189,"sitemap":190,"stem":191,"tags":181,"__hash__":192},"vueTips\u002Fvue-tips\u002Fuse-teleport-to-render-a-component-in-a-different-place\u002Findex.md","Vue Tip: Use Teleport to Render a Component in a Different Place",{"type":56,"value":57,"toc":174},"minimark",[58,70,73,76,79,155,162,170],[59,60,61,62,69],"p",{},"The built-in ",[63,64,68],"a",{"href":65,"rel":66},"https:\u002F\u002Fv3.vuejs.org\u002Fguide\u002Fteleport.html#teleport",[67],"nofollow","Vue 3 Teleport component"," allows us to render HTML outside\nthe Vue.js application. This can be useful to position modals, toast notifications, overlays, and more.",[59,71,72],{},"Sometimes, a component's template belongs logically to the component itself.\nAt the same time, from a technical point of view, moving this part of the template elsewhere in the DOM, outside of the Vue app, would be preferable.",[59,74,75],{},"A full-screen modal is a common scenario where you'd want to handle the modal's logic inside the component, but it should be positioned at a completely different place.",[59,77,78],{},"Teleport provides a clean way to allow us to control under which parent in the DOM we want a piece of HTML to be rendered,\nwithout having to resort to a global state or splitting this into two components:",[80,81,86],"pre",{"className":82,"code":83,"language":84,"meta":85,"style":85},"language-vue shiki shiki-themes github-light poimandres poimandres","\u003Ctemplate>\n  \u003Cteleport to=\"body\"> This will be appended to the body tag \u003C\u002Fteleport>\n\u003C\u002Ftemplate>\n","vue","",[87,88,89,105,146],"code",{"__ignoreMap":85},[90,91,94,98,102],"span",{"class":92,"line":93},"line",1,[90,95,97],{"class":96},"sMzB8","\u003C",[90,99,101],{"class":100},"s8PnL","template",[90,103,104],{"class":96},">\n",[90,106,108,111,114,118,122,126,130,132,135,139,142,144],{"class":92,"line":107},2,[90,109,110],{"class":96},"  \u003C",[90,112,113],{"class":100},"teleport",[90,115,117],{"class":116},"sppiw"," to",[90,119,121],{"class":120},"sygvE","=",[90,123,125],{"class":124},"srEIG","\"",[90,127,129],{"class":128},"skTdI","body",[90,131,125],{"class":124},[90,133,134],{"class":96},">",[90,136,138],{"class":137},"syBNg"," This will be appended to the body tag ",[90,140,141],{"class":96},"\u003C\u002F",[90,143,113],{"class":100},[90,145,104],{"class":96},[90,147,149,151,153],{"class":92,"line":148},3,[90,150,141],{"class":96},[90,152,101],{"class":100},[90,154,104],{"class":96},[59,156,157,158,161],{},"The ",[87,159,160],{},"to"," attribute should be a valid CSS selector outside the Vue application.",[59,163,164,165,169],{},"Read more about Teleport in the ",[63,166,168],{"href":65,"rel":167},[67],"official documentation",".",[171,172,173],"style",{},"html pre.shiki code .sMzB8, html code.shiki .sMzB8{--shiki-light:#24292E;--shiki-default:#E4F0FB;--shiki-dark:#E4F0FB}html pre.shiki code .s8PnL, html code.shiki .s8PnL{--shiki-light:#22863A;--shiki-default:#5DE4C7;--shiki-dark:#5DE4C7}html pre.shiki code .sppiw, html code.shiki .sppiw{--shiki-light:#6F42C1;--shiki-light-font-style:inherit;--shiki-default:#91B4D5;--shiki-default-font-style:italic;--shiki-dark:#91B4D5;--shiki-dark-font-style:italic}html pre.shiki code .sygvE, html code.shiki .sygvE{--shiki-light:#24292E;--shiki-default:#A6ACCD;--shiki-dark:#A6ACCD}html pre.shiki code .srEIG, html code.shiki .srEIG{--shiki-light:#032F62;--shiki-default:#A6ACCD;--shiki-dark:#A6ACCD}html pre.shiki code .skTdI, html code.shiki .skTdI{--shiki-light:#032F62;--shiki-default:#5DE4C7;--shiki-dark:#5DE4C7}html pre.shiki code .syBNg, html code.shiki .syBNg{--shiki-light:#24292E;--shiki-default:#5DE4C7;--shiki-dark:#5DE4C7}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":85,"searchDepth":107,"depth":107,"links":175},[],[101],"vue-tips\u002Fuse-teleport-to-render-a-component-in-a-different-place-static-v1.jpg","2022-01-09","With teleport, you can render a component in a different place in the DOM tree, even if this place is not in your app's scope.","md",null,{},"\u002Fvue-tips\u002Fuse-teleport-to-render-a-component-in-a-different-place",{"text":185,"minutes":186,"time":187,"words":188},"1 min read",0.795,47700,159,{"title":54,"description":179},{"loc":183,"lastmod":178},"vue-tips\u002Fuse-teleport-to-render-a-component-in-a-different-place\u002Findex","0Fv_Uox54GGcByJdWL4CLl1zvB7knpQxK7XfbdHmlR4",{"id":194,"title":54,"body":195,"cover":177,"description":179,"extension":180,"meta":267,"navigation":11,"path":183,"robots":181,"seo":270,"sitemap":271,"stem":191,"__hash__":272},"content\u002Fvue-tips\u002Fuse-teleport-to-render-a-component-in-a-different-place\u002Findex.md",{"type":56,"value":196,"toc":265},[197,202,204,206,208,254,258,263],[59,198,61,199,69],{},[63,200,68],{"href":65,"rel":201},[67],[59,203,72],{},[59,205,75],{},[59,207,78],{},[80,209,210],{"className":82,"code":83,"language":84,"meta":85,"style":85},[87,211,212,220,246],{"__ignoreMap":85},[90,213,214,216,218],{"class":92,"line":93},[90,215,97],{"class":96},[90,217,101],{"class":100},[90,219,104],{"class":96},[90,221,222,224,226,228,230,232,234,236,238,240,242,244],{"class":92,"line":107},[90,223,110],{"class":96},[90,225,113],{"class":100},[90,227,117],{"class":116},[90,229,121],{"class":120},[90,231,125],{"class":124},[90,233,129],{"class":128},[90,235,125],{"class":124},[90,237,134],{"class":96},[90,239,138],{"class":137},[90,241,141],{"class":96},[90,243,113],{"class":100},[90,245,104],{"class":96},[90,247,248,250,252],{"class":92,"line":148},[90,249,141],{"class":96},[90,251,101],{"class":100},[90,253,104],{"class":96},[59,255,157,256,161],{},[87,257,160],{},[59,259,164,260,169],{},[63,261,168],{"href":65,"rel":262},[67],[171,264,173],{},{"title":85,"searchDepth":107,"depth":107,"links":266},[],{"date":178,"categories":268,"readingTime":269},[101],{"text":185,"minutes":186,"time":187,"words":188},{"title":54,"description":179},{"loc":183,"lastmod":178},"imIKGerF0cn7Osg8dy0olbaAKect3rL_g1ffgF99BGI",[274,278],{"title":275,"path":276,"stem":277,"children":-1},"Vue Tip: Automatic Global Registration of Base Components","\u002Fvue-tips\u002Fautomatic-global-registration-of-base-components","vue-tips\u002Fautomatic-global-registration-of-base-components\u002Findex",{"title":279,"path":280,"stem":281,"children":-1},"Vue Tip: Assign Handler for Uncaught Errors","\u002Fvue-tips\u002Fassign-handler-for-uncaught-errors","vue-tips\u002Fassign-handler-for-uncaught-errors\u002Findex"]