[{"_path":"/pages/home","_draft":false,"_partial":false,"_empty":false,"title":"Home","description":"Hey, I'm Evan Yang, a full-stack web developer living in China. I'm passionate about building open-source packages in the Vue, Nuxt and Vite ecosystems.","excerpt":{"type":"root","children":[{"type":"element","tag":"h1","props":{"id":"evan-yang-"},"children":[{"type":"text","value":"Evan-Yang "},{"type":"element","tag":"i-line-md-coffee-loop","props":{},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Hey, I am Evan Yang, a front-end developer from China."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Core team member of "},{"type":"element","tag":"a","props":{"href":"https://github.com/anse-app","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Anse"}]},{"type":"text","value":", "},{"type":"element","tag":"a","props":{"href":"https://github.com/onu-ui/onu-ui","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"OnuUI"}]},{"type":"text","value":"."},{"type":"element","tag":"br","props":{},"children":[]},{"type":"text","value":"\nCreator of "},{"type":"element","tag":"a","props":{"href":"https://github.com/vbs-plus/magic-cli","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"magic-cli"}]},{"type":"text","value":", "},{"type":"element","tag":"a","props":{"href":"https://github.com/vbs-plus/zi","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"za-zi"}]},{"type":"text","value":",  "},{"type":"element","tag":"a","props":{"href":"https://github.com/vbs-plus/json-tsc","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"json-tsc"}]},{"type":"text","value":" and others."},{"type":"element","tag":"br","props":{},"children":[]},{"type":"text","value":"\nContributor of "},{"type":"element","tag":"a","props":{"href":"https://github.com/ddiu8081/chatgpt-demo","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"chatgpt-demo"}]},{"type":"text","value":", "},{"type":"element","tag":"a","props":{"href":"https://github.com/unocss/unocss","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"UnoCSS"}]},{"type":"text","value":", "},{"type":"element","tag":"a","props":{"href":"https://github.com/vitest-dev/vitest","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Vitest"}]},{"type":"text","value":", "},{"type":"element","tag":"a","props":{"href":"https://github.com/antfu/vitesse-nuxt3","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Vitesse-nuxt3"}]},{"type":"text","value":" and more."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Dreaming up ideas and making them come true is where my passion lies. You can find my "},{"type":"element","tag":"a","props":{"href":"/projects"},"children":[{"type":"text","value":"full projects list here"}]},{"type":"text","value":"."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Currently I am focusing on front-end technologies that help people design complex applications to be simpler to use, enabling functionality while optimizing the user experience."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"I love to chase ideas and I spend a lot of time using some great product applications, learning from their successes and using them to inspire my creativity."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Find me on "},{"type":"element","tag":"a","props":{"href":"https://github.com/yzh990918","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"element","tag":"i-simple-icons-github","props":{},"children":[]},{"type":"text","value":" GitHub"}]},{"type":"text","value":", "},{"type":"element","tag":"a","props":{"href":"https://twitter.com/zhihaoy18640576","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"element","tag":"i-simple-icons-twitter","props":{},"children":[]},{"type":"text","value":" Twitter"}]},{"type":"text","value":", "},{"type":"element","tag":"a","props":{"href":"https://juejin.cn/user/1855631359227079","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"element","tag":"i-simple-icons-googleallo","props":{},"children":[]},{"type":"text","value":" 掘金"}]},{"type":"text","value":", "},{"type":"element","tag":"a","props":{"href":"https://www.zhihu.com/people/nu-li-zhong-de-yang-xian-sheng-85","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"element","tag":"i-simple-icons-zhihu","props":{},"children":[]},{"type":"text","value":" 知乎"}]},{"type":"text","value":" or "},{"type":"element","tag":"a","props":{"href":"https://b23.tv/wq3YwlB","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"element","tag":"i-simple-icons-bilibili","props":{},"children":[]},{"type":"text","value":" 哔哩哔哩"}]},{"type":"text","value":"."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Mail me at "},{"type":"element","tag":"i-simple-icons-gmail","props":{},"children":[]},{"type":"text","value":" "},{"type":"element","tag":"a","props":{"href":"mailto:mohen1024@gmail.com"},"children":[{"type":"text","value":"mohen1024@gmail.com"}]},{"type":"text","value":"."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"If you like my works, you can add "},{"type":"element","tag":"a","props":{"href":"https://github.com/yzh990918?tab=repositories","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"star to my projects"}]},{"type":"text","value":"."}]}]},"head":{"title":"Evan's blog"},"body":{"type":"root","children":[{"type":"element","tag":"Breadcrumbs"},{"type":"element","tag":"h1","props":{"id":"evan-yang-"},"children":[{"type":"text","value":"Evan-Yang "},{"type":"element","tag":"svg","props":{"preserveAspectRatio":"xMidYMid meet","viewBox":"0 0 24 24","width":"1em","height":"1em","aria-hidden":true,"title":"coffee-loop","innerHTML":"<g fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\"><path stroke-dasharray=\"48\" stroke-dashoffset=\"48\" d=\"M17 9v9a3 3 0 0 1-3 3H8a3 3 0 0 1-3-3V9z\"><animate fill=\"freeze\" attributeName=\"stroke-dashoffset\" dur=\"0.6s\" values=\"48;0\"></animate></path><path stroke-dasharray=\"14\" stroke-dashoffset=\"14\" d=\"M17 14H20C20.55 14 21 13.55 21 13V10C21 9.45 20.55 9 20 9H17\"><animate fill=\"freeze\" attributeName=\"stroke-dashoffset\" begin=\"0.6s\" dur=\"0.2s\" values=\"14;28\"></animate></path></g><mask id=\"svgIDa\"><path fill=\"none\" stroke=\"#fff\" stroke-width=\"2\" d=\"M8 0c0 2-2 2-2 4s2 2 2 4-2 2-2 4 2 2 2 4M12 0c0 2-2 2-2 4s2 2 2 4-2 2-2 4 2 2 2 4M16 0c0 2-2 2-2 4s2 2 2 4-2 2-2 4 2 2 2 4\"><animateMotion calcMode=\"linear\" dur=\"3s\" path=\"M0 0v-8\" repeatCount=\"indefinite\"></animateMotion></path></mask><rect width=\"24\" height=\"0\" y=\"7\" fill=\"currentColor\" mask=\"url(#svgIDa)\"><animate fill=\"freeze\" attributeName=\"y\" begin=\"0.8s\" dur=\"0.6s\" values=\"7;2\"></animate><animate fill=\"freeze\" attributeName=\"height\" begin=\"0.8s\" dur=\"0.6s\" values=\"0;5\"></animate></rect>","style":{"display":"inline-block","vertical-align":"text-bottom"}},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Hey, I am Evan Yang, a front-end developer from China."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Core team member of "},{"type":"element","tag":"a","props":{"href":"https://github.com/anse-app","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Anse"}]},{"type":"text","value":", "},{"type":"element","tag":"a","props":{"href":"https://github.com/onu-ui/onu-ui","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"OnuUI"}]},{"type":"text","value":"."},{"type":"element","tag":"br","props":{},"children":[]},{"type":"text","value":"\nCreator of "},{"type":"element","tag":"a","props":{"href":"https://github.com/vbs-plus/magic-cli","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"magic-cli"}]},{"type":"text","value":", "},{"type":"element","tag":"a","props":{"href":"https://github.com/vbs-plus/zi","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"za-zi"}]},{"type":"text","value":",  "},{"type":"element","tag":"a","props":{"href":"https://github.com/vbs-plus/json-tsc","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"json-tsc"}]},{"type":"text","value":" and others."},{"type":"element","tag":"br","props":{},"children":[]},{"type":"text","value":"\nContributor of "},{"type":"element","tag":"a","props":{"href":"https://github.com/ddiu8081/chatgpt-demo","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"chatgpt-demo"}]},{"type":"text","value":", "},{"type":"element","tag":"a","props":{"href":"https://github.com/unocss/unocss","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"UnoCSS"}]},{"type":"text","value":", "},{"type":"element","tag":"a","props":{"href":"https://github.com/vitest-dev/vitest","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Vitest"}]},{"type":"text","value":", "},{"type":"element","tag":"a","props":{"href":"https://github.com/antfu/vitesse-nuxt3","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Vitesse-nuxt3"}]},{"type":"text","value":" and more."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Dreaming up ideas and making them come true is where my passion lies. You can find my "},{"type":"element","tag":"a","props":{"href":"/projects"},"children":[{"type":"text","value":"full projects list here"}]},{"type":"text","value":"."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Currently I am focusing on front-end technologies that help people design complex applications to be simpler to use, enabling functionality while optimizing the user experience."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"I love to chase ideas and I spend a lot of time using some great product applications, learning from their successes and using them to inspire my creativity."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Find me on "},{"type":"element","tag":"a","props":{"href":"https://github.com/yzh990918","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"element","tag":"svg","props":{"preserveAspectRatio":"xMidYMid meet","viewBox":"0 0 24 24","width":"1em","height":"1em","aria-hidden":true,"title":"github","innerHTML":"<path fill=\"currentColor\" d=\"M12 .297c-6.63 0-12 5.373-12 12c0 5.303 3.438 9.8 8.205 11.385c.6.113.82-.258.82-.577c0-.285-.01-1.04-.015-2.04c-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729c1.205.084 1.838 1.236 1.838 1.236c1.07 1.835 2.809 1.305 3.495.998c.108-.776.417-1.305.76-1.605c-2.665-.3-5.466-1.332-5.466-5.93c0-1.31.465-2.38 1.235-3.22c-.135-.303-.54-1.523.105-3.176c0 0 1.005-.322 3.3 1.23c.96-.267 1.98-.399 3-.405c1.02.006 2.04.138 3 .405c2.28-1.552 3.285-1.23 3.285-1.23c.645 1.653.24 2.873.12 3.176c.765.84 1.23 1.91 1.23 3.22c0 4.61-2.805 5.625-5.475 5.92c.42.36.81 1.096.81 2.22c0 1.606-.015 2.896-.015 3.286c0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12\"></path>","style":{"display":"inline-block","vertical-align":"text-bottom"}},"children":[]},{"type":"text","value":" GitHub"}]},{"type":"text","value":", "},{"type":"element","tag":"a","props":{"href":"https://twitter.com/zhihaoy18640576","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"element","tag":"svg","props":{"preserveAspectRatio":"xMidYMid meet","viewBox":"0 0 24 24","width":"1em","height":"1em","aria-hidden":true,"title":"twitter","innerHTML":"<path fill=\"currentColor\" d=\"M23.953 4.57a10 10 0 0 1-2.825.775a4.958 4.958 0 0 0 2.163-2.723c-.951.555-2.005.959-3.127 1.184a4.92 4.92 0 0 0-8.384 4.482C7.69 8.095 4.067 6.13 1.64 3.162a4.822 4.822 0 0 0-.666 2.475c0 1.71.87 3.213 2.188 4.096a4.904 4.904 0 0 1-2.228-.616v.06a4.923 4.923 0 0 0 3.946 4.827a4.996 4.996 0 0 1-2.212.085a4.936 4.936 0 0 0 4.604 3.417a9.867 9.867 0 0 1-6.102 2.105c-.39 0-.779-.023-1.17-.067a13.995 13.995 0 0 0 7.557 2.209c9.053 0 13.998-7.496 13.998-13.985c0-.21 0-.42-.015-.63A9.935 9.935 0 0 0 24 4.59z\"></path>","style":{"display":"inline-block","vertical-align":"text-bottom"}},"children":[]},{"type":"text","value":" Twitter"}]},{"type":"text","value":", "},{"type":"element","tag":"a","props":{"href":"https://juejin.cn/user/1855631359227079","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"element","tag":"svg","props":{"preserveAspectRatio":"xMidYMid meet","viewBox":"0 0 24 24","width":"1em","height":"1em","aria-hidden":true,"title":"googleallo","innerHTML":"<path d=\"M11.665.005c-.702.018-1.417.098-2.14.243C4.788 1.193 1.08 4.974.21 9.728c-1.36 7.406 4.096 14.256 11.16 14.256L22.227 24c.98 0 1.774-.793 1.774-1.774V12C24 5.26 18.445-.18 11.665.005zM12 6.135A5.863 5.863 0 0 1 17.862 12v5.61a.273.273 0 0 1-.467.194l-1.46-1.46a5.864 5.864 0 1 1-3.936-10.209z\" fill=\"currentColor\"></path>","style":{"display":"inline-block","vertical-align":"text-bottom"}},"children":[]},{"type":"text","value":" 掘金"}]},{"type":"text","value":", "},{"type":"element","tag":"a","props":{"href":"https://www.zhihu.com/people/nu-li-zhong-de-yang-xian-sheng-85","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"element","tag":"svg","props":{"preserveAspectRatio":"xMidYMid meet","viewBox":"0 0 24 24","width":"1em","height":"1em","aria-hidden":true,"title":"zhihu","innerHTML":"<path fill=\"currentColor\" d=\"M5.721 0C2.251 0 0 2.25 0 5.719V18.28C0 21.751 2.252 24 5.721 24h12.56C21.751 24 24 21.75 24 18.281V5.72C24 2.249 21.75 0 18.281 0zm1.964 4.078c-.271.73-.5 1.434-.68 2.11h4.587c.545-.006.445 1.168.445 1.171H9.384a58.104 58.104 0 0 1-.112 3.797h2.712c.388.023.393 1.251.393 1.266H9.183a9.223 9.223 0 0 1-.408 2.102l.757-.604c.452.456 1.512 1.712 1.906 2.177c.473.681.063 2.081.063 2.081l-2.794-3.382c-.653 2.518-1.845 3.607-1.845 3.607c-.523.468-1.58.82-2.64.516c2.218-1.73 3.44-3.917 3.667-6.497H4.491c0-.015.197-1.243.806-1.266h2.71c.024-.32.086-3.254.086-3.797H6.598c-.136.406-.158.447-.268.753c-.594 1.095-1.603 1.122-1.907 1.155c.906-1.821 1.416-3.6 1.591-4.064c.425-1.124 1.671-1.125 1.671-1.125zM13.078 6h6.377v11.33h-2.573l-2.184 1.373l-.401-1.373h-1.219zm1.313 1.219v8.86h.623l.263.937l1.455-.938h1.456v-8.86z\"></path>","style":{"display":"inline-block","vertical-align":"text-bottom"}},"children":[]},{"type":"text","value":" 知乎"}]},{"type":"text","value":" or "},{"type":"element","tag":"a","props":{"href":"https://b23.tv/wq3YwlB","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"element","tag":"svg","props":{"preserveAspectRatio":"xMidYMid meet","viewBox":"0 0 24 24","width":"1em","height":"1em","aria-hidden":true,"title":"bilibili","innerHTML":"<path fill=\"currentColor\" d=\"M17.813 4.653h.854c1.51.054 2.769.578 3.773 1.574c1.004.995 1.524 2.249 1.56 3.76v7.36c-.036 1.51-.556 2.769-1.56 3.773s-2.262 1.524-3.773 1.56H5.333c-1.51-.036-2.769-.556-3.773-1.56S.036 18.858 0 17.347v-7.36c.036-1.511.556-2.765 1.56-3.76c1.004-.996 2.262-1.52 3.773-1.574h.774l-1.174-1.12a1.234 1.234 0 0 1-.373-.906c0-.356.124-.658.373-.907l.027-.027c.267-.249.573-.373.92-.373c.347 0 .653.124.92.373L9.653 4.44c.071.071.134.142.187.213h4.267a.836.836 0 0 1 .16-.213l2.853-2.747c.267-.249.573-.373.92-.373c.347 0 .662.151.929.4c.267.249.391.551.391.907c0 .355-.124.657-.373.906zM5.333 7.24c-.746.018-1.373.276-1.88.773c-.506.498-.769 1.13-.786 1.894v7.52c.017.764.28 1.395.786 1.893c.507.498 1.134.756 1.88.773h13.334c.746-.017 1.373-.275 1.88-.773c.506-.498.769-1.129.786-1.893v-7.52c-.017-.765-.28-1.396-.786-1.894c-.507-.497-1.134-.755-1.88-.773zM8 11.107c.373 0 .684.124.933.373c.25.249.383.569.4.96v1.173c-.017.391-.15.711-.4.96c-.249.25-.56.374-.933.374s-.684-.125-.933-.374c-.25-.249-.383-.569-.4-.96V12.44c0-.373.129-.689.386-.947c.258-.257.574-.386.947-.386zm8 0c.373 0 .684.124.933.373c.25.249.383.569.4.96v1.173c-.017.391-.15.711-.4.96c-.249.25-.56.374-.933.374s-.684-.125-.933-.374c-.25-.249-.383-.569-.4-.96V12.44c.017-.391.15-.711.4-.96c.249-.249.56-.373.933-.373Z\"></path>","style":{"display":"inline-block","vertical-align":"text-bottom"}},"children":[]},{"type":"text","value":" 哔哩哔哩"}]},{"type":"text","value":"."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Mail me at "},{"type":"element","tag":"svg","props":{"preserveAspectRatio":"xMidYMid meet","viewBox":"0 0 24 24","width":"1em","height":"1em","aria-hidden":true,"title":"gmail","innerHTML":"<path fill=\"currentColor\" d=\"M24 5.457v13.909c0 .904-.732 1.636-1.636 1.636h-3.819V11.73L12 16.64l-6.545-4.91v9.273H1.636A1.636 1.636 0 0 1 0 19.366V5.457c0-2.023 2.309-3.178 3.927-1.964L5.455 4.64L12 9.548l6.545-4.91l1.528-1.145C21.69 2.28 24 3.434 24 5.457z\"></path>","style":{"display":"inline-block","vertical-align":"text-bottom"}},"children":[]},{"type":"text","value":" "},{"type":"element","tag":"a","props":{"href":"mailto:mohen1024@gmail.com"},"children":[{"type":"text","value":"mohen1024@gmail.com"}]},{"type":"text","value":"."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"If you like my works, you can add "},{"type":"element","tag":"a","props":{"href":"https://github.com/yzh990918?tab=repositories","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"star to my projects"}]},{"type":"text","value":"."}]}],"toc":{"title":"","searchDepth":2,"depth":2,"links":[]}},"_type":"markdown","_id":"content:pages:1.home.md","_source":"content","_file":"pages/1.home.md","_extension":"md","storageMeta":{"atime":"2023-06-16T10:26:05.626Z","mtime":"2023-06-16T10:26:05.626Z","size":1827},"readingMins":1,"path":"/","renderer":"page","schemaOrg":{"publishedAt":"2023-06-16T10:26:05.626Z","modifiedAt":"2023-06-16T10:26:05.626Z"},"publishedAt":"2023-06-16T10:26:05.626Z","modifiedAt":"2023-06-16T10:26:05.626Z"},{"_path":"/pages/blog","_draft":false,"_partial":false,"_empty":false,"title":"Blog","description":"This is a directory of the articles I have written and published that are sometimes updated.","excerpt":{"type":"root","children":[{"type":"element","tag":"prose","props":{},"children":[{"type":"element","tag":"h1","props":{"id":"blog-"},"children":[{"type":"text","value":"Blog "},{"type":"element","tag":"i-line-md-text-box-multiple","props":{},"children":[]}]}]},{"type":"element","tag":"post-list","props":{},"children":[]}]},"prose":false,"schema":{"type":"CollectionPage"},"icon":{"preserveAspectRatio":"xMidYMid meet","viewBox":"0 0 24 24","width":"1em","height":"1em","aria-hidden":true,"title":"text-box-multiple","innerHTML":"<g fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\"><path stroke-dasharray=\"62\" stroke-dashoffset=\"62\" d=\"M22 4V3C22 2.45 21.55 2 21 2H7C6.45 2 6 2.45 6 3V17C6 17.55 6.45 18 7 18H21C21.55 18 22 17.55 22 17z\"><animate fill=\"freeze\" attributeName=\"stroke-dashoffset\" dur=\"0.6s\" values=\"62;124\"></animate></path><g stroke-dasharray=\"10\" stroke-dashoffset=\"10\"><path d=\"M10 6h8\"><animate fill=\"freeze\" attributeName=\"stroke-dashoffset\" begin=\"0.7s\" dur=\"0.2s\" values=\"10;0\"></animate></path><path d=\"M10 10h8\"><animate fill=\"freeze\" attributeName=\"stroke-dashoffset\" begin=\"0.9s\" dur=\"0.2s\" values=\"10;0\"></animate></path></g><path stroke-dasharray=\"7\" stroke-dashoffset=\"7\" d=\"M10 14h5\"><animate fill=\"freeze\" attributeName=\"stroke-dashoffset\" begin=\"1.1s\" dur=\"0.2s\" values=\"7;0\"></animate></path><path stroke-dasharray=\"34\" stroke-dashoffset=\"34\" d=\"M2 6V21C2 21.55 2.45 22 3 22H18\"><animate fill=\"freeze\" attributeName=\"stroke-dashoffset\" begin=\"1.4s\" dur=\"0.4s\" values=\"34;68\"></animate></path></g>"},"nav":true,"body":{"type":"root","children":[{"type":"element","tag":"prose","props":{},"children":[{"type":"element","tag":"Breadcrumbs"},{"type":"element","tag":"h1","props":{"id":"blog-"},"children":[{"type":"text","value":"Blog "},{"type":"element","tag":"svg","props":{"preserveAspectRatio":"xMidYMid meet","viewBox":"0 0 24 24","width":"1em","height":"1em","aria-hidden":true,"title":"text-box-multiple","innerHTML":"<g fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\"><path stroke-dasharray=\"62\" stroke-dashoffset=\"62\" d=\"M22 4V3C22 2.45 21.55 2 21 2H7C6.45 2 6 2.45 6 3V17C6 17.55 6.45 18 7 18H21C21.55 18 22 17.55 22 17z\"><animate fill=\"freeze\" attributeName=\"stroke-dashoffset\" dur=\"0.6s\" values=\"62;124\"></animate></path><g stroke-dasharray=\"10\" stroke-dashoffset=\"10\"><path d=\"M10 6h8\"><animate fill=\"freeze\" attributeName=\"stroke-dashoffset\" begin=\"0.7s\" dur=\"0.2s\" values=\"10;0\"></animate></path><path d=\"M10 10h8\"><animate fill=\"freeze\" attributeName=\"stroke-dashoffset\" begin=\"0.9s\" dur=\"0.2s\" values=\"10;0\"></animate></path></g><path stroke-dasharray=\"7\" stroke-dashoffset=\"7\" d=\"M10 14h5\"><animate fill=\"freeze\" attributeName=\"stroke-dashoffset\" begin=\"1.1s\" dur=\"0.2s\" values=\"7;0\"></animate></path><path stroke-dasharray=\"34\" stroke-dashoffset=\"34\" d=\"M2 6V21C2 21.55 2.45 22 3 22H18\"><animate fill=\"freeze\" attributeName=\"stroke-dashoffset\" begin=\"1.4s\" dur=\"0.4s\" values=\"34;68\"></animate></path></g>","style":{"display":"inline-block","vertical-align":"text-bottom"}},"children":[]}]}]},{"type":"element","tag":"post-list","props":{},"children":[]}],"toc":{"title":"","searchDepth":2,"depth":2,"links":[]}},"_type":"markdown","_id":"content:pages:blog.md","_source":"content","_file":"pages/blog.md","_extension":"md","storageMeta":{"atime":"2023-06-16T10:26:05.626Z","mtime":"2023-06-16T10:26:05.626Z","size":277},"readingMins":1,"path":"/blog","renderer":"page","schemaOrg":{"publishedAt":"2023-06-16T10:26:05.626Z","modifiedAt":"2023-06-16T10:26:05.626Z"},"publishedAt":"2023-06-16T10:26:05.626Z","modifiedAt":"2023-06-16T10:26:05.626Z"},{"_path":"/pages/projects","_draft":false,"_partial":false,"_empty":false,"title":"Projects","description":"This is a directory of the open-source packages and tools I've released that are actively maintained.","excerpt":{"type":"root","children":[{"type":"element","tag":"prose","props":{},"children":[{"type":"element","tag":"h1","props":{"id":"projects-"},"children":[{"type":"text","value":"Projects "},{"type":"element","tag":"i-line-md-lightbulb","props":{},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"This is a directory of the open-source packages and tools.  You can find all of my projects on "},{"type":"element","tag":"a","props":{"href":"https://github.com/yzh990918","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"GitHub"}]},{"type":"text","value":"."}]}]},{"type":"element","tag":"project-list","props":{},"children":[]}]},"prose":false,"schema":{"type":"CollectionPage"},"icon":{"preserveAspectRatio":"xMidYMid meet","viewBox":"0 0 24 24","width":"1em","height":"1em","aria-hidden":true,"title":"lightbulb","innerHTML":"<path fill=\"none\" stroke=\"currentColor\" stroke-dasharray=\"46\" stroke-dashoffset=\"46\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M12 17H9V14.1973C7.2066 13.1599 6 11.2208 6 9C6 5.68629 8.68629 3 12 3C15.3137 3 18 5.68629 18 9C18 11.2208 16.7934 13.1599 15 14.1973V17z\"><animate fill=\"freeze\" attributeName=\"stroke-dashoffset\" dur=\"0.4s\" values=\"46;0\"></animate></path><rect width=\"6\" height=\"0\" x=\"9\" y=\"20\" fill=\"currentColor\" rx=\"1\"><animate fill=\"freeze\" attributeName=\"height\" begin=\"0.5s\" dur=\"0.2s\" values=\"0;2\"></animate></rect>"},"nav":true,"body":{"type":"root","children":[{"type":"element","tag":"prose","props":{},"children":[{"type":"element","tag":"Breadcrumbs"},{"type":"element","tag":"h1","props":{"id":"projects-"},"children":[{"type":"text","value":"Projects "},{"type":"element","tag":"svg","props":{"preserveAspectRatio":"xMidYMid meet","viewBox":"0 0 24 24","width":"1em","height":"1em","aria-hidden":true,"title":"lightbulb","innerHTML":"<path fill=\"none\" stroke=\"currentColor\" stroke-dasharray=\"46\" stroke-dashoffset=\"46\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M12 17H9V14.1973C7.2066 13.1599 6 11.2208 6 9C6 5.68629 8.68629 3 12 3C15.3137 3 18 5.68629 18 9C18 11.2208 16.7934 13.1599 15 14.1973V17z\"><animate fill=\"freeze\" attributeName=\"stroke-dashoffset\" dur=\"0.4s\" values=\"46;0\"></animate></path><rect width=\"6\" height=\"0\" x=\"9\" y=\"20\" fill=\"currentColor\" rx=\"1\"><animate fill=\"freeze\" attributeName=\"height\" begin=\"0.5s\" dur=\"0.2s\" values=\"0;2\"></animate></rect>","style":{"display":"inline-block","vertical-align":"text-bottom"}},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"This is a directory of the open-source packages and tools.  You can find all of my projects on "},{"type":"element","tag":"a","props":{"href":"https://github.com/yzh990918","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"GitHub"}]},{"type":"text","value":"."}]}]},{"type":"element","tag":"project-list","props":{},"children":[]}],"toc":{"title":"","searchDepth":2,"depth":2,"links":[]}},"_type":"markdown","_id":"content:pages:projects.md","_source":"content","_file":"pages/projects.md","_extension":"md","storageMeta":{"atime":"2023-06-16T10:26:05.626Z","mtime":"2023-06-16T10:26:05.626Z","size":417},"readingMins":1,"path":"/projects","renderer":"page","schemaOrg":{"publishedAt":"2023-06-16T10:26:05.626Z","modifiedAt":"2023-06-16T10:26:05.626Z"},"publishedAt":"2023-06-16T10:26:05.626Z","modifiedAt":"2023-06-16T10:26:05.626Z"},{"_path":"/posts/change-skin","_draft":false,"_partial":false,"_empty":false,"title":"前端换肤方案总结","description":"常可以看到一些网站会有类似暗黑模式/白天模式的主题切换功能，效果也是十分炫酷，在平时的开发场景中也有越来越多这样的需求，这里大致罗列一些常见的主题切换方案并分析其优劣，大家可根据需求综合分析得出一套适用的方案。","excerpt":"I used Vite to build a new blazing fast blog ⚡, find out what I learnt and why Vite is the next big thing.","publishedAt":"2023-02-09","status":"published","tags":["vue"],"body":{"type":"root","children":[{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"toc","props":{},"children":[]}]},{"type":"element","tag":"Image","props":{"alt":"img","src":"https://cdn.nlark.com/yuque/0/2023/webp/785653/1675754048268-90db1a56-b969-4e8a-89bc-1b78dbeacc36.webp"},"children":[]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"现在我们经常可以看到一些网站会有类似暗黑模式/白天模式的主题切换功能，效果也是十分炫酷，在平时的开发场景中也有越来越多这样的需求，这里大致罗列一些常见的主题切换方案并分析其优劣，大家可根据需求综合分析得出一套适用的方案。"}]},{"type":"element","tag":"h2","props":{"id":"方案1link标签动态引入"},"children":[{"type":"text","value":"方案1：link标签动态引入"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"其做法就是提前准备好几套CSS主题样式文件，在需要的时候，创建link标签动态加载到head标签中，或者是动态改变link标签的href属性。"}]},{"type":"element","tag":"Image","props":{"alt":"img","src":"https://cdn.nlark.com/yuque/0/2023/webp/785653/1675754048225-87ee1866-4bcc-4fa3-9a54-20e52928d8dd.webp"},"children":[]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"表现效果如下："}]},{"type":"element","tag":"Image","props":{"alt":"img","src":"https://cdn.nlark.com/yuque/0/2023/webp/785653/1675754048193-f3508653-9381-4282-ba48-95565c5f5a5c.webp"},"children":[]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"网络请求如下："}]},{"type":"element","tag":"Image","props":{"alt":"img","src":"https://cdn.nlark.com/yuque/0/2023/webp/785653/1675754048228-3eee2af5-7c6f-4a0c-a7eb-7c95c09455f4.webp"},"children":[]},{"type":"element","tag":"h3","props":{"id":"优点"},"children":[{"type":"text","value":"优点："}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"实现了按需加载，提高了首屏加载时的性能"}]}]},{"type":"element","tag":"h3","props":{"id":"缺点"},"children":[{"type":"text","value":"缺点："}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"动态加载样式文件，如果文件过大网络情况不佳的情况下可能会有加载延迟，导致样式切换不流畅"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"如果主题样式表内定义不当，会有优先级问题"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"各个主题样式是写死的，后续针对某一主题样式表修改或者新增主题也很麻烦"}]}]},{"type":"element","tag":"h2","props":{"id":"方案2提前引入所有主题样式做类名切换"},"children":[{"type":"text","value":"方案2：提前引入所有主题样式，做类名切换"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"这种方案与第一种比较类似，为了解决反复加载样式文件问题提前将样式全部引入，在需要切换主题的时候将指定的根元素类名更换，相当于直接做了样式覆盖，在该类名下的各个样式就统一地更换了。其基本方法如下："}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"css","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"/* day样式主题 */\nbody.day .box {\n  color: #f90;\n  background: #fff;\n}\n/* dark样式主题 */\nbody.dark .box {\n  color: #eee;\n  background: #333;\n}\n\n.box {\n  width: 100px;\n  height: 100px;\n  border: 1px solid #000;\n}\n<div class=\"box\">\n  <p>hello</p>\n</div>\n<p>\n  选择样式：\n  <button onclick=\"change('day')\">day</button>\n  <button onclick=\"change('dark')\">dark</button>\n</p>\nfunction change(theme) {\n  document.body.className = theme;\n}\n","language":"css"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"/* day样式主题 */"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"body"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"day"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"box"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"color"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"f90"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"background"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"fff"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"/* dark样式主题 */"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"body"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"dark"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"box"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"color"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"eee"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"background"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"333"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"box"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"width"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"100px"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"height"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"100px"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"border"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"1px"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" solid "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"000"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"div"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" class=\"box\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"p"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"hello</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"p"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"div"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"p"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  选择样式："}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"button"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" onclick=\"change('day')\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"day</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"button"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"button"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" onclick=\"change('dark')\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"dark</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"button"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"p"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"function change(theme) "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  document.body.className = theme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"表现效果如下："}]},{"type":"element","tag":"Image","props":{"alt":"img","src":"https://cdn.nlark.com/yuque/0/2023/webp/785653/1675754048199-edba8f2f-d3d0-4c8d-b8be-ddefceba31c7.webp"},"children":[]},{"type":"element","tag":"h3","props":{"id":"优点-1"},"children":[{"type":"text","value":"优点："}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"不用重新加载样式文件，在样式切换时不会有卡顿"}]}]},{"type":"element","tag":"h3","props":{"id":"缺点-1"},"children":[{"type":"text","value":"缺点："}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"首屏加载时会牺牲一些时间加载样式资源"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"如果主题样式表内定义不当，也会有优先级问题"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"各个主题样式是写死的，后续针对某一主题样式表修改或者新增主题也很麻烦"}]}]},{"type":"element","tag":"h2","props":{"id":"方案小结"},"children":[{"type":"text","value":"方案小结"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"通过以上两个方案，我们可以看到对于样式的加载问题上的考量就类似于在纠结是做SPA单页应用还是MPA多页应用项目一样。两种其实都误伤大雅，但是最重要的是要保证在后续的持续开发迭代中怎样会更方便。因此我们还可以基于以上存在的问题和方案做进一步的增强。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"在做主题切换技术调研时，看到了网友的一条建议："}]},{"type":"element","tag":"Image","props":{"alt":"img","src":"https://cdn.nlark.com/yuque/0/2023/webp/785653/1675754050239-305323b6-a4fb-456b-ad03-6e51688029c9.webp"},"children":[]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"因此下面的几个方案主要是针对变量来做样式切换"}]},{"type":"element","tag":"h2","props":{"id":"方案3css变量类名切换"},"children":[{"type":"text","value":"方案3：CSS变量+类名切换"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"灵感参考："},{"type":"element","tag":"a","props":{"href":"https://link.juejin.cn/?target=https%3A%2F%2Fstaging-cn.vuejs.org%2F","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Vue3官网"}]},{"type":"text","value":"在Vue3官网有一个暗黑模式切换按钮，点击之后就会平滑地过渡，虽然Vue3中也有一个v-bind特性可以实现动态样式绑定，但经过观察以后Vue官网并没有采取这个方案，针对Vue3的v-bind特性在接下来的方案中会细说。大体思路跟方案2相似，依然是提前将样式文件载入，切换时将指定的根元素类名更换。不过这里相对灵活的是，默认在根作用域下定义好CSS变量，只需要在不同的主题下更改CSS变量对应的取值即可。顺带提一下，在Vue3官网还使用了color-scheme: dark;将系统的滚动条设置为了黑色模式，使样式更加统一。"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"css","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"html.dark {\n  color-scheme: dark;\n}\n","language":"css"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"html"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"dark"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  color-scheme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" dark"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"实现方案如下："}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"css","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"/* 定义根作用域下的变量 */\n:root {\n  --theme-color: #333;\n  --theme-background: #eee;\n}\n/* 更改dark类名下变量的取值 */\n.dark{\n  --theme-color: #eee;\n  --theme-background: #333;\n}\n/* 更改pink类名下变量的取值 */\n.pink{\n  --theme-color: #fff;\n  --theme-background: pink;\n}\n\n.box {\n  transition: all .2s;\n  width: 100px;\n  height: 100px;\n  border: 1px solid #000;\n  /* 使用变量 */\n  color: var(--theme-color);\n  background: var(--theme-background);\n}\n\n","language":"css"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"/* 定义根作用域下的变量 */"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"root"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  --theme-color"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"333"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  --theme-background"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"eee"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"/* 更改dark类名下变量的取值 */"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"dark"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  --theme-color"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"eee"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  --theme-background"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"333"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"/* 更改pink类名下变量的取值 */"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"pink"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  --theme-color"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"fff"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  --theme-background"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" pink"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"box"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"transition"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" all "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":".2s"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"width"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"100px"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"height"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"100px"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"border"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"1px"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" solid "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"000"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"/* 使用变量 */"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"color"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"var"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"--theme-color"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":");"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"background"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"var"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"--theme-background"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":");"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"表现效果如下："}]},{"type":"element","tag":"Image","props":{"alt":"img","src":"https://cdn.nlark.com/yuque/0/2023/webp/785653/1675754050730-ec55fbe8-0d5c-4fc2-8f16-597286e7da84.webp"},"children":[]},{"type":"element","tag":"h3","props":{"id":"优点-2"},"children":[{"type":"text","value":"优点："}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"不用重新加载样式文件，在样式切换时不会有卡顿"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"在需要切换主题的地方利用var()绑定变量即可，不存在优先级问题"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"新增或修改主题方便灵活，仅需新增或修改CSS变量即可，在var()绑定样式变量的地方就会自动更换"}]}]},{"type":"element","tag":"h3","props":{"id":"缺点-2"},"children":[{"type":"text","value":"缺点："}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"IE兼容性（忽略不计）"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"首屏加载时会牺牲一些时间加载样式资源"}]}]},{"type":"element","tag":"h2","props":{"id":"方案4vue3新特性v-bind"},"children":[{"type":"text","value":"方案4：Vue3新特性（v-bind）"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"虽然这种方式存在局限性只能在Vue开发中使用，但是为Vue项目开发者做动态样式更改提供了又一个不错的方案。"}]},{"type":"element","tag":"h3","props":{"id":"简单用法"},"children":[{"type":"text","value":"简单用法"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"html","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"<script setup>\n  // 这里可以是原始对象值，也可以是ref()或reactive()包裹的值，根据具体需求而定\n  const theme = {\n    color: 'red'\n  }\n</script>\n\n<template>\n<p>hello</p>\n</template>\n\n<style scoped>\n  p {\n    color: v-bind('theme.color');\n  }\n</style>\n","language":"html"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"setup"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 这里可以是原始对象值，也可以是ref()或reactive()包裹的值，根据具体需求而定"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" theme "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"color"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"red"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"p"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"hello"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"p"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"style"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"scoped"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"p"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"color"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" v-bind("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"theme.color"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"style"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Vue3中在style样式通过v-bind()绑定变量的原理其实就是给元素绑定CSS变量，在绑定的数据更新时调用 "},{"type":"element","tag":"a","props":{"href":"https://link.juejin.cn/?target=https%3A%2F%2Fdeveloper.mozilla.org%2Fzh-CN%2Fdocs%2FWeb%2FAPI%2FCSSStyleDeclaration%2FsetProperty","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"CSSStyleDeclaration.setProperty"}]},{"type":"text","value":" 更新CSS变量值。"}]},{"type":"element","tag":"h3","props":{"id":"实现思考"},"children":[{"type":"text","value":"实现思考"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"前面方案3基于CSS变量绑定样式是在:root上定义变量，然后在各个地方都可以获取到根元素上定义的变量。现在的方案我们需要考虑的问题是，如果是基于JS层面如何在各个组件上优雅地使用统一的样式变量？我们可以利用Vuex或Pinia对全局样式变量做统一管理，如果不想使用类似的插件也可以自行封装一个hook，大致如下："}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"ts","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"// 定义暗黑主题变量\nexport default {\n  fontSize: '16px',\n  fontColor: '#eee',\n  background: '#333',\n};\n// 定义白天主题变量\nexport default {\n  fontSize: '20px',\n  fontColor: '#f90',\n  background: '#eee',\n};\nimport { shallowRef } from 'vue';\n// 引入主题\nimport theme_day from './theme_day';\nimport theme_dark from './theme_dark';\n\n// 定义在全局的样式变量\nconst theme = shallowRef({});\n\nexport function useTheme() {\n  // 尝试从本地读取\n  const localTheme = localStorage.getItem('theme');\n  theme.value = localTheme ? JSON.parse(localTheme) : theme_day;\n  \n  const setDayTheme = () => {\n    theme.value = theme_day;\n  };\n  \n  const setDarkTheme = () => {\n    theme.value = theme_dark;\n  };\n  \n  return {\n    theme,\n    setDayTheme,\n    setDarkTheme,\n  };\n}\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 定义暗黑主题变量"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"fontSize"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"16px"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"fontColor"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"#eee"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"background"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"#333"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"};"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 定义白天主题变量"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"fontSize"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"20px"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"fontColor"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"#f90"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"background"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"#eee"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"};"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"shallowRef"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 引入主题"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" theme_day "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"./theme_day"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" theme_dark "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"./theme_dark"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 定义在全局的样式变量"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" theme "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"shallowRef"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"useTheme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 尝试从本地读取"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"localTheme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"localStorage"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"getItem"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"theme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"theme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"value"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"localTheme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"?"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"JSON"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"parse"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"localTheme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"theme_day"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"setDayTheme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"theme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"value"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"theme_day"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"};"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"setDarkTheme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"theme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"value"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"theme_dark"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"};"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"theme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"setDayTheme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"setDarkTheme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"};"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"使用自己封装的主题hook"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"vue","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"<script setup lang=\"ts\">\nimport { useTheme } from './useTheme.ts';\nimport MyButton from './components/MyButton.vue';\n  \nconst { theme } = useTheme();\n</script>\n\n<template>\n  <div class=\"box\">\n    <span>Hello</span>\n  </div>\n  <my-button />\n</template>\n\n<style lang=\"scss\">\n.box {\n  width: 100px;\n  height: 100px;\n  background: v-bind('theme.background');\n  color: v-bind('theme.fontColor');\n  font-size: v-bind('theme.fontSize');\n}\n</style>\n<script setup lang=\"ts\">\nimport { useTheme } from '../useTheme.ts';\n  \nconst { theme, setDarkTheme, setDayTheme } = useTheme();\n  \nconst change1 = () => {\n  setDarkTheme();\n};\n  \nconst change2 = () => {\n  setDayTheme();\n};\n</script>\n\n<template>\n  <button class=\"my-btn\" @click=\"change1\">dark</button>\n  <button class=\"my-btn\" @click=\"change2\">day</button>\n</template>\n\n<style scoped lang=\"scss\">\n.my-btn {\n  color: v-bind('theme.fontColor');\n  background: v-bind('theme.background');\n}\n</style>\n","language":"vue"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"setup"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"lang"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"ts"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"useTheme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"./useTheme.ts"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" MyButton "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"./components/MyButton.vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" theme "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"useTheme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"div"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"class"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"box"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"span"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"Hello"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"span"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  </"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"div"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"my-button"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" />"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"style"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"lang"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"scss"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"box"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" {"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"width:"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" 100px;"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"height:"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" 100px;"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"background:"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"v-bind"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"theme.background"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":");"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"color:"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"v-bind"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"theme.fontColor"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":");"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"font-size:"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"v-bind"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"theme.fontSize"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":");"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"style"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"setup"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"lang"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"ts"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"useTheme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"../useTheme.ts"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" theme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" setDarkTheme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" setDayTheme "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"useTheme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" change1 "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"setDarkTheme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"};"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" change2 "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"setDayTheme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"};"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"button"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"class"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"my-btn"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"@"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"click"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"change1"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"dark"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"button"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"button"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"class"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"my-btn"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"@"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"click"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"change2"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"day"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"button"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"style"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"scoped"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"lang"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"scss"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"my-btn"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" {"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"color:"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"v-bind"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"theme.fontColor"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":");"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"background:"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"v-bind"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"theme.background"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":");"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"style"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"表现效果如下："}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"Image","props":{"alt":"img","src":"https://cdn.nlark.com/yuque/0/2023/webp/785653/1675754054897-fa23acba-7789-452f-baf4-fe9e808fc4e3.webp"},"children":[]},{"type":"text","value":"其实从这里可以看到，跟Vue的响应式原理一样，只要数据发生改变，Vue就会把绑定了变量的地方通通更新。"}]},{"type":"element","tag":"h3","props":{"id":"优点-3"},"children":[{"type":"text","value":"优点："}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"不用重新加载样式文件，在样式切换时不会有卡顿"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"在需要切换主题的地方利用v-bind绑定变量即可，不存在优先级问题"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"新增或修改主题方便灵活，仅需新增或修改JS变量即可，在v-bind()绑定样式变量的地方就会自动更换"}]}]},{"type":"element","tag":"h3","props":{"id":"缺点-3"},"children":[{"type":"text","value":"缺点："}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"IE兼容性（忽略不计）"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"首屏加载时会牺牲一些时间加载样式资源"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"这种方式只要是在组件上绑定了动态样式的地方都会有对应的编译成哈希化的CSS变量，而不像方案3统一地就在:root上设置（不确定在达到一定量级以后的性能），也可能正是如此，Vue官方也并未采用此方式做全站的主题切换"}]}]},{"type":"element","tag":"h2","props":{"id":"方案5scss--mixin--类名切换"},"children":[{"type":"text","value":"方案5：SCSS + mixin + 类名切换"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"主要是运用SCSS的混合+CSS类名切换，其原理主要是将使用到mixin混合的地方编译为固定的CSS以后，再通过类名切换去做样式的覆盖，实现方案如下："},{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"定义SCSS变量"}]},{"type":"text","value":"："}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"css","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"/* 字体定义规范 */\n$font_samll:12Px;\n$font_medium_s:14Px;\n$font_medium:16Px;\n$font_large:18Px;\n\n/* 背景颜色规范(主要) */\n$background-color-theme: #d43c33;//背景主题颜色默认(网易红)\n$background-color-theme1: #42b983;//背景主题颜色1(QQ绿)\n$background-color-theme2: #333;//背景主题颜色2(夜间模式)\n\n/* 背景颜色规范(次要) */ \n$background-color-sub-theme: #f5f5f5;//背景主题颜色默认(网易红)\n$background-color-sub-theme1: #f5f5f5;//背景主题颜色1(QQ绿)\n$background-color-sub-theme2: #444;//背景主题颜色2(夜间模式)\n\n/* 字体颜色规范(默认) */\n$font-color-theme : #666;//字体主题颜色默认(网易)\n$font-color-theme1 : #666;//字体主题颜色1(QQ)\n$font-color-theme2 : #ddd;//字体主题颜色2(夜间模式)\n\n/* 字体颜色规范(激活) */\n$font-active-color-theme : #d43c33;//字体主题颜色默认(网易红)\n$font-active-color-theme1 : #42b983;//字体主题颜色1(QQ绿)\n$font-active-color-theme2 : #ffcc33;//字体主题颜色2(夜间模式)\n\n/* 边框颜色 */\n$border-color-theme : #d43c33;//边框主题颜色默认(网易)\n$border-color-theme1 : #42b983;//边框主题颜色1(QQ)\n$border-color-theme2 : #ffcc33;//边框主题颜色2(夜间模式)\n\n/* 字体图标颜色 */\n$icon-color-theme : #ffffff;//边框主题颜色默认(网易)\n$icon-color-theme1 : #ffffff;//边框主题颜色1(QQ)\n$icon-color-theme2 : #ffcc2f;//边框主题颜色2(夜间模式)\n$icon-theme : #d43c33;//边框主题颜色默认(网易)\n$icon-theme1 : #42b983;//边框主题颜色1(QQ)\n$icon-theme2 : #ffcc2f;//边框主题颜色2(夜间模式)\n\n","language":"css"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"/* 字体定义规范 */"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$font_samll:12Px;"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$font_medium_s:14Px;"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$font_medium:16Px;"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$font_large:18Px;"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"/* 背景颜色规范(主要) */"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"background-color-theme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":": "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"d43c33;//背景主题颜色默认(网易红)"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"background-color-theme1"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":": "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"42b983;//背景主题颜色1(QQ绿)"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"background-color-theme2"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":": "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"333;//背景主题颜色2(夜间模式)"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"/* 背景颜色规范(次要) */"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"background-color-sub-theme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":": "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"f5f5f5;//背景主题颜色默认(网易红)"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"background-color-sub-theme1"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":": "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"f5f5f5;//背景主题颜色1(QQ绿)"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"background-color-sub-theme2"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":": "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"444;//背景主题颜色2(夜间模式)"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"/* 字体颜色规范(默认) */"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"font-color-theme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" : "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"666;//字体主题颜色默认(网易)"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"font-color-theme1"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" : "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"666;//字体主题颜色1(QQ)"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"font-color-theme2"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" : "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"ddd;//字体主题颜色2(夜间模式)"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"/* 字体颜色规范(激活) */"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"font-active-color-theme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" : "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"d43c33;//字体主题颜色默认(网易红)"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"font-active-color-theme1"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" : "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"42b983;//字体主题颜色1(QQ绿)"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"font-active-color-theme2"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" : "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"ffcc33;//字体主题颜色2(夜间模式)"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"/* 边框颜色 */"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"border-color-theme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" : "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"d43c33;//边框主题颜色默认(网易)"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"border-color-theme1"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" : "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"42b983;//边框主题颜色1(QQ)"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"border-color-theme2"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" : "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"ffcc33;//边框主题颜色2(夜间模式)"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"/* 字体图标颜色 */"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"icon-color-theme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" : "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"ffffff;//边框主题颜色默认(网易)"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"icon-color-theme1"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" : "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"ffffff;//边框主题颜色1(QQ)"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"icon-color-theme2"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" : "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"ffcc2f;//边框主题颜色2(夜间模式)"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"icon-theme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" : "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"d43c33;//边框主题颜色默认(网易)"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"icon-theme1"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" : "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"42b983;//边框主题颜色1(QQ)"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"icon-theme2"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" : "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"ffcc2f;//边框主题颜色2(夜间模式)"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"定义混合mixin"}]},{"type":"text","value":"："}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"css","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"@import \"./variable.scss\";\n\n@mixin bg_color(){\n  background: $background-color-theme;\n  [data-theme=theme1] & {\n    background: $background-color-theme1;\n  }\n  [data-theme=theme2] & {\n    background: $background-color-theme2;\n  }\n}\n@mixin bg_sub_color(){\n  background: $background-color-sub-theme;\n  [data-theme=theme1] & {\n    background: $background-color-sub-theme1;\n  }\n  [data-theme=theme2] & {\n    background: $background-color-sub-theme2;\n  }\n}\n\n@mixin font_color(){\n  color: $font-color-theme;\n  [data-theme=theme1] & {\n    color: $font-color-theme1;\n  }\n  [data-theme=theme2] & {\n    color: $font-color-theme2;\n  }\n}\n@mixin font_active_color(){\n  color: $font-active-color-theme;\n  [data-theme=theme1] & {\n    color: $font-active-color-theme1;\n  }\n  [data-theme=theme2] & {\n    color: $font-active-color-theme2;\n  }\n}\n\n@mixin icon_color(){\n    color: $icon-color-theme;\n    [data-theme=theme1] & {\n        color: $icon-color-theme1;\n    }\n    [data-theme=theme2] & {\n        color: $icon-color-theme2;\n    }\n}\n\n@mixin border_color(){\n  border-color: $border-color-theme;\n  [data-theme=theme1] & {\n    border-color: $border-color-theme1;\n  }\n  [data-theme=theme2] & {\n    border-color: $border-color-theme2;\n  }\n}\n<template>\n  <div class=\"header\" @click=\"changeTheme\">\n    <div class=\"header-left\">\n      <slot name=\"left\">左边</slot>\n    </div>\n    <slot name=\"center\" class=\"\">中间</slot>\n    <div class=\"header-right\">\n      <slot name=\"right\">右边</slot>\n    </div>\n  </div>\n</template>\n\n<script>\n  export default {\n    name: 'Header',\n    methods: {\n      changeTheme () {\n        document.documentElement.setAttribute('data-theme', 'theme1')\n      }\n    }\n  }\n</script>\n\n<style scoped lang=\"scss\">\n@import \"../assets/css/variable\";\n@import \"../assets/css/mixin\";\n.header{\n  width: 100%;\n  height: 100px;\n  font-size: $font_medium;\n  @include bg_color();\n}\n</style>\n","language":"css"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"@import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"./variable.scss"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"@mixin"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" bg_color()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  background: $"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"background-color-theme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"["}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"data-theme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"theme1"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" & "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"background"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" $background-color-theme1"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"["}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"data-theme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"theme2"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" & "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"background"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" $background-color-theme2"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"@mixin"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" bg_sub_color()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  background: $"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"background-color-sub-theme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"["}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"data-theme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"theme1"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" & "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"background"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" $background-color-sub-theme1"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"["}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"data-theme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"theme2"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" & "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"background"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" $background-color-sub-theme2"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"@mixin"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" font_color()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  color: $"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"font-color-theme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"["}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"data-theme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"theme1"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" & "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"color"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" $font-color-theme1"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"["}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"data-theme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"theme2"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" & "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"color"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" $font-color-theme2"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"@mixin"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" font_active_color()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  color: $"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"font-active-color-theme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"["}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"data-theme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"theme1"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" & "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"color"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" $font-active-color-theme1"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"["}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"data-theme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"theme2"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" & "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"color"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" $font-active-color-theme2"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"@mixin"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" icon_color()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    color: $"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"icon-color-theme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"["}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"data-theme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"theme1"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" & "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"color"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" $icon-color-theme1"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"["}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"data-theme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"theme2"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" & "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"color"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" $icon-color-theme2"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"@mixin"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" border_color()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"border-color"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":": $"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"border-color-theme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"["}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"data-theme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"theme1"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" & "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"border-color"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" $border-color-theme1"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"["}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"data-theme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"theme2"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" & "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"border-color"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" $border-color-theme2"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"div"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" class=\"header\" @click=\"changeTheme\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"div"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" class=\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"header-left"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"      <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"slot"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" name=\"left\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"左边</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"slot"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    </"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"div"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"slot"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" name=\"center\" class=\"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"中间</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"slot"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"div"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" class=\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"header-right"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"      <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"slot"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" name=\"right\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"右边</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"slot"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    </"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"div"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  </"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"div"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  export default "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"name"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"Header"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    methods: {"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"      changeTheme () {"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        document.documentElement.setAttribute('data-theme', 'theme1')"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    }"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  }"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"style"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" scoped lang=\"scss\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"@import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"../assets/css/variable"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"@import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"../assets/css/mixin"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"header"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"width"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"100%"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"height"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"100px"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"font-size"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" $font_medium"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  @include bg_color()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"style"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"表现效果如下："}]},{"type":"element","tag":"Image","props":{"alt":"img","src":"https://cdn.nlark.com/yuque/0/2023/webp/785653/1675754054944-24f0582f-5b32-40d2-8c90-81075b444d48.webp"},"children":[]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"可以发现，使用mixin混合在SCSS编译后同样也是将所有包含的样式全部加载："}]},{"type":"element","tag":"Image","props":{"alt":"img","src":"https://cdn.nlark.com/yuque/0/2023/webp/785653/1675754057187-0917c66d-d0e7-436d-83d4-1cd7fb9c6c83.webp"},"children":[]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"这种方案最后得到的结果与方案2类似，只是在定义主题时由于是直接操作的SCSS变量，会更加灵活。"}]},{"type":"element","tag":"h3","props":{"id":"优点-4"},"children":[{"type":"text","value":"优点："}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"不用重新加载样式文件，在样式切换时不会有卡顿"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"在需要切换主题的地方利用mixin混合绑定变量即可，不存在优先级问题"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"新增或修改主题方便灵活，仅需新增或修改SCSS变量即可，经过编译后会将所有主题全部编译出来"}]}]},{"type":"element","tag":"h3","props":{"id":"缺点-4"},"children":[{"type":"text","value":"缺点："}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"首屏加载时会牺牲一些时间加载样式资源"}]}]},{"type":"element","tag":"h2","props":{"id":"方案6css变量动态setproperty"},"children":[{"type":"text","value":"方案6：CSS变量+动态setProperty"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"此方案较于前几种会更加灵活，不过视情况而定，这个方案适用于由用户根据颜色面板自行设定各种颜色主题，这种是主题颜色不确定的情况，而前几种方案更适用于定义预设的几种主题。方案参考："},{"type":"element","tag":"a","props":{"href":"https://link.juejin.cn/?target=https%3A%2F%2Fgitee.com%2Fkailong110120130%2Fvue-element-plus-admin","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"vue-element-plus-admin"}]},{"type":"text","value":" 主要实现思路如下：只需在全局中设置好预设的全局CSS变量样式，无需单独为每一个主题类名下重新设定CSS变量值，因为主题是由用户"},{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"动态"}]},{"type":"text","value":"决定。"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"css","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":":root {\n  --theme-color: #333;\n  --theme-background: #eee;\n}\n\n","language":"css"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"root"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  --theme-color"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"333"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  --theme-background"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"eee"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"定义一个工具类方法，用于修改指定的CSS变量值，调用的是 "},{"type":"element","tag":"a","props":{"href":"https://link.juejin.cn/?target=https%3A%2F%2Fdeveloper.mozilla.org%2Fzh-CN%2Fdocs%2FWeb%2FAPI%2FCSSStyleDeclaration%2FsetProperty","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"CSSStyleDeclaration.setProperty"}]}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"ts","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"export const setCssVar = (prop: string, val: any, dom = document.documentElement) => {\n  dom.style.setProperty(prop, val)\n}\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" setCssVar "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"prop"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"string"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" val"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"any"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" dom "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" document"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"documentElement"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"dom"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"style"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"setProperty"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"prop"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"val"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"在样式发生改变时调用此方法即可"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"css","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"setCssVar('--theme-color', color)\n","language":"css"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"setCssVar('--theme-color'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" color)"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"表现效果如下："}]},{"type":"element","tag":"Image","props":{"alt":"img","src":"https://cdn.nlark.com/yuque/0/2023/webp/785653/1675754061190-6e558904-d356-4b11-9182-f19aaa18cd99.webp"},"children":[]},{"type":"element","tag":"h3","props":{"id":"vue-element-plus-admin主题切换源码"},"children":[{"type":"text","value":"vue-element-plus-admin主题切换源码："}]},{"type":"element","tag":"Image","props":{"alt":"img","src":"https://cdn.nlark.com/yuque/0/2023/webp/785653/1675754080022-2e8d5215-b933-49c6-a82c-288583c49931.webp"},"children":[]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"这里还用了vueuse的useCssVar不过效果和Vue3中使用v-bind绑定动态样式是差不多的，底层都是调用的 "},{"type":"element","tag":"a","props":{"href":"https://link.juejin.cn/?target=https%3A%2F%2Fdeveloper.mozilla.org%2Fzh-CN%2Fdocs%2FWeb%2FAPI%2FCSSStyleDeclaration%2FsetProperty","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"CSSStyleDeclaration.setProperty"}]},{"type":"text","value":" 这个api，这里就不多赘述vueuse中的用法。"}]},{"type":"element","tag":"Image","props":{"alt":"img","src":"https://cdn.nlark.com/yuque/0/2023/webp/785653/1675754084423-a5cc7c16-1567-42f9-b861-37e7ebe524ce.webp"},"children":[]},{"type":"element","tag":"h3","props":{"id":"优点-5"},"children":[{"type":"text","value":"优点："}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"不用重新加载样式文件，在样式切换时不会有卡顿"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"仔细琢磨可以发现其原理跟方案4利用Vue3的新特性v-bind是一致的，只不过此方案只在:root上动态更改CSS变量而Vue3中会将CSS变量绑定到任何依赖该变量的节点上。"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"需要切换主题的地方只用在:root上动态更改CSS变量值即可，不存在优先级问题"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"新增或修改主题方便灵活"}]}]},{"type":"element","tag":"h3","props":{"id":"缺点-5"},"children":[{"type":"text","value":"缺点："}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"IE兼容性（忽略不计）"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"首屏加载时会牺牲一些时间加载样式资源（相对于前几种预设好的主题，这种方式的样式定义在首屏加载基本可以忽略不计）"}]}]},{"type":"element","tag":"h2","props":{"id":"方案总结"},"children":[{"type":"text","value":"方案总结"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"说明：两种主题方案都支持并不代表一定是最佳方案，视具体情况而定。"}]},{"type":"element","tag":"Image","props":{"alt":"image.png","src":"https://cdn.nlark.com/yuque/0/2023/png/785653/1676028576681-79fe1e79-ff66-477a-866c-73690a998fa6.png?x-oss-process=image%2Fresize%2Cw_1500%2Climit_0"},"children":[]}],"toc":{"title":"","searchDepth":2,"depth":2,"links":[{"id":"方案1link标签动态引入","depth":2,"text":"方案1：link标签动态引入","children":[{"id":"优点","depth":3,"text":"优点："},{"id":"缺点","depth":3,"text":"缺点："}]},{"id":"方案2提前引入所有主题样式做类名切换","depth":2,"text":"方案2：提前引入所有主题样式，做类名切换","children":[{"id":"优点-1","depth":3,"text":"优点："},{"id":"缺点-1","depth":3,"text":"缺点："}]},{"id":"方案小结","depth":2,"text":"方案小结"},{"id":"方案3css变量类名切换","depth":2,"text":"方案3：CSS变量+类名切换","children":[{"id":"优点-2","depth":3,"text":"优点："},{"id":"缺点-2","depth":3,"text":"缺点："}]},{"id":"方案4vue3新特性v-bind","depth":2,"text":"方案4：Vue3新特性（v-bind）","children":[{"id":"简单用法","depth":3,"text":"简单用法"},{"id":"实现思考","depth":3,"text":"实现思考"},{"id":"优点-3","depth":3,"text":"优点："},{"id":"缺点-3","depth":3,"text":"缺点："}]},{"id":"方案5scss--mixin--类名切换","depth":2,"text":"方案5：SCSS + mixin + 类名切换","children":[{"id":"优点-4","depth":3,"text":"优点："},{"id":"缺点-4","depth":3,"text":"缺点："}]},{"id":"方案6css变量动态setproperty","depth":2,"text":"方案6：CSS变量+动态setProperty","children":[{"id":"vue-element-plus-admin主题切换源码","depth":3,"text":"vue-element-plus-admin主题切换源码："},{"id":"优点-5","depth":3,"text":"优点："},{"id":"缺点-5","depth":3,"text":"缺点："}]},{"id":"方案总结","depth":2,"text":"方案总结"}]}},"_type":"markdown","_id":"content:posts:change-skin.md","_source":"content","_file":"posts/change-skin.md","_extension":"md","storageMeta":{"atime":"2023-06-16T10:26:05.626Z","mtime":"2023-06-16T10:26:05.626Z","size":17382},"readingMins":1,"path":"/blog/change-skin","renderer":"post","schemaOrg":{"modifiedAt":"2023-06-16T10:26:05.626Z"},"modifiedAt":"2023-06-16T10:26:05.626Z"},{"_path":"/posts/congratulations-to-mr.-dai","_draft":false,"_partial":false,"_empty":false,"title":"究竟要怎样的结局,才配得上这颠沛的一路","description":"恭喜 DRX 击败 T1 拿下 S12 冠军!","excerpt":{"type":"root","children":[{"type":"element","tag":"h2","props":{"id":"deft-其实人生在世不需要别人建议的亲身经历才行"},"children":[{"type":"text","value":"Deft: 其实人生在世不需要别人建议的，亲身经历才行"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","src":"https://raw.githubusercontent.com/imageList/imglist/master/img/20221108111719.png"},"children":[]}]}]},"publishedAt":"2022-11-06","status":"published","body":{"type":"root","children":[{"type":"element","tag":"h2","props":{"id":"deft-其实人生在世不需要别人建议的亲身经历才行"},"children":[{"type":"text","value":"Deft: 其实人生在世不需要别人建议的，亲身经历才行"}]},{"type":"element","tag":"Image","props":{"alt":"","src":"https://raw.githubusercontent.com/imageList/imglist/master/img/20221108111719.png"},"children":[]}],"toc":{"title":"","searchDepth":2,"depth":2,"links":[{"id":"deft-其实人生在世不需要别人建议的亲身经历才行","depth":2,"text":"Deft: 其实人生在世不需要别人建议的，亲身经历才行"}]}},"_type":"markdown","_id":"content:posts:Congratulations to Mr. Dai.md","_source":"content","_file":"posts/Congratulations to Mr. Dai.md","_extension":"md","storageMeta":{"atime":"2023-06-16T10:26:05.626Z","mtime":"2023-06-16T10:26:05.626Z","size":334},"readingMins":1,"path":"/blog/congratulations-to-mr.-dai","renderer":"post","schemaOrg":{"modifiedAt":"2023-06-16T10:26:05.626Z"},"modifiedAt":"2023-06-16T10:26:05.626Z"},{"_path":"/posts/how-the-heck-does-vite-work","_draft":false,"_partial":false,"_empty":false,"title":"How Does Vite Work - A Comparison to webpack","description":"A deep-dive into the comparisons between the earliest Vite version and webpack. Discover what I learnt digging into internals and how I, correctly, guessed Vite was the next big thing.","excerpt":"I used Vite to build a new blazing fast blog ⚡, find out what I learnt and why Vite is the next big thing.","publishedAt":"2020-12-01","status":"published","tags":["webpack","vite"],"body":{"type":"root","children":[{"type":"element","tag":"toc","props":{},"children":[]},{"type":"element","tag":"tip","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Note: This article was written for the alpha of Vite. I'd recommend reading Patak's great article on "},{"type":"element","tag":"a","props":{"href":"https://patak.dev/vite/ecosystem.html","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"The Vite Ecosystem"}]},{"type":"text","value":"."}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"In rebuilding my old Nuxt.js personal site, I wanted to challenge myself to learn the latest tech, the unknown."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The unknown was the new project by Evan You: "},{"type":"element","tag":"a","props":{"href":"https://github.com/vitejs/vite","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"⚡ Vite"}]},{"type":"text","value":" (/veet/). Called Fast, for the 🇫🇷 Frenchies."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"I'll be comparing how Vite works to the standard "},{"type":"element","tag":"a","props":{"href":"https://github.com/webpack/webpack","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"webpack"}]},{"type":"text","value":" config using "},{"type":"element","tag":"a","props":{"href":"https://github.com/webpack/webpack-dev-server","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"webpack-dev-server"}]},{"type":"text","value":", which all major Vue frameworks\nare using."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"We'll be looking at how Vite no-bundling works, by first looking at how webpack's bundling works and what the difference is. Afterwards I'll give you some\nrecommendations for setting up Vite for yourself."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Vite could the next best thing in tooling, currently, it's still in a pre-release stage though so be careful out there 🐛."}]},{"type":"element","tag":"h2","props":{"id":"a-recap-on-vite"},"children":[{"type":"text","value":"A Recap on Vite"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Vite is a web development build tool which supports Vue, React and Preact. It's an experimental new direction in how build tools can work with a greenfield ecosystem."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Vite's core functionality is similar to webpack + webpack-dev-server with some core improvements\non developer experience:"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"⌛ Less time waiting for your app to start, regardless of app size"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"🔥 Hot module reloading (HMR) that is basically instant, regardless of app size"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"🔨 On-demand compilation"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"🙅‍♂️ Zero configuration for numerous pre-processors out of the box"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"📜 Esbuild powered typescript / jsx (super quick)"}]}]},{"type":"element","tag":"h3","props":{"id":"speed-example"},"children":[{"type":"text","value":"Speed Example"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"To give you a quick idea on how much faster it is, the below comparison is for Vue CLI which uses webpack. The bigger your app\nis the more noticeable the speed difference will be."}]},{"type":"element","tag":"figure","props":{},"children":[{"type":"element","tag":"table","props":{},"children":[{"type":"element","tag":"thead","props":{},"children":[{"type":"element","tag":"tr","props":{},"children":[{"type":"element","tag":"th","props":{"align":null},"children":[]},{"type":"element","tag":"th","props":{"align":"right"},"children":[{"type":"text","value":"Build Time"}]},{"type":"element","tag":"th","props":{"align":"right"},"children":[{"type":"text","value":"Dev Server Start Time"}]},{"type":"element","tag":"th","props":{"align":"right"},"children":[{"type":"text","value":"Dev Page Load Time"}]}]}]},{"type":"element","tag":"tbody","props":{},"children":[{"type":"element","tag":"tr","props":{},"children":[{"type":"element","tag":"td","props":{"align":null},"children":[{"type":"text","value":"Vue CLI"}]},{"type":"element","tag":"td","props":{"align":"right"},"children":[{"type":"element","tag":"span","props":{"className":["text-red-400"]},"children":[{"type":"text","value":"5.14s"}]}]},{"type":"element","tag":"td","props":{"align":"right"},"children":[{"type":"element","tag":"span","props":{"className":["text-red-400"]},"children":[{"type":"text","value":"2568ms"}]}]},{"type":"element","tag":"td","props":{"align":"right"},"children":[{"type":"element","tag":"span","props":{"className":["text-yellow-400"]},"children":[{"type":"text","value":"320ms"}]}]}]},{"type":"element","tag":"tr","props":{},"children":[{"type":"element","tag":"td","props":{"align":null},"children":[{"type":"text","value":"Vite"}]},{"type":"element","tag":"td","props":{"align":"right"},"children":[{"type":"element","tag":"span","props":{"className":["text-green-500"]},"children":[{"type":"text","value":"2.39s"}]}]},{"type":"element","tag":"td","props":{"align":"right"},"children":[{"type":"element","tag":"span","props":{"className":["text-green-500"]},"children":[{"type":"text","value":"232ms"}]},{"type":"text","value":"️"}]},{"type":"element","tag":"td","props":{"align":"right"},"children":[{"type":"element","tag":"span","props":{"className":["text-yellow-500"]},"children":[{"type":"text","value":"379ms"}]}]}]}]}]},{"type":"element","tag":"figcaption","props":{},"children":[{"type":"text","value":"New Vue 3 project / 10 components / no Babel / 2nd run, in development."}]}]},{"type":"element","tag":"h2","props":{"id":"vite-vs-webpack"},"children":[{"type":"text","value":"Vite vs webpack"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The main functional difference you'll notice with Vite and your webpack app, is how code is served in development and which modules are supported."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Don't worry if the below terms don't make sense to you, we'll be exploring them below."}]},{"type":"element","tag":"h3","props":{"id":"webpack-nuxtjs--vue-cli--etc"},"children":[{"type":"text","value":"webpack (Nuxt.js / Vue CLI / etc)"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Supported Modules: "},{"type":"element","tag":"a","props":{"href":"https://www.2ality.com/2014/09/es6-modules-final.html","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"ES Modules"}]},{"type":"text","value":", "},{"type":"element","tag":"a","props":{"href":"http://wiki.commonjs.org/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"CommonJS"}]},{"type":"text","value":" and "},{"type":"element","tag":"a","props":{"href":"https://github.com/amdjs/amdjs-api/wiki/AMD","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"AMD Modules"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Dev Server: Bundled modules served via webpack-dev-server using "},{"type":"element","tag":"a","props":{"href":"https://expressjs.com/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Express.js"}]},{"type":"text","value":" web server"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Production Build: webpack"}]}]},{"type":"element","tag":"h3","props":{"id":"vite"},"children":[{"type":"text","value":"Vite"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Supported Modules: "},{"type":"element","tag":"a","props":{"href":"https://www.2ality.com/2014/09/es6-modules-final.html","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"ES Modules"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Dev Server: Native-ES-Modules, served via Vite using a "},{"type":"element","tag":"a","props":{"href":"https://github.com/koajs/koa","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Koa"}]},{"type":"text","value":" web server"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Production build: "},{"type":"element","tag":"a","props":{"href":"https://github.com/rollup/rollup","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Rollup"}]}]}]},{"type":"element","tag":"tip","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Check out Mozilla's "},{"type":"element","tag":"a","props":{"href":"https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/","target":"_blank"},"children":[{"type":"text","value":"article"}]},{"type":"text","value":" on ES Modules if they're new to you."}]}]},{"type":"element","tag":"h2","props":{"id":"understanding-webpack"},"children":[{"type":"text","value":"Understanding webpack"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"To understand how Vite works, it's best to look at how webpack works first. Even with its popularly, understanding webpack can be intimidating, so I'll try to keep it simple."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"webpack is versatile in what you can do with it, but at its core, it will:"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Starting with an entry file, build a tree of your dependencies: all the imports, exports, requires from your code/files"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Transform / compile modules: think transpiling js for older browsers, turning SCSS into CSS"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Use algorithms to sort, rewrite and concatenate code"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Optimise"}]}]},{"type":"element","tag":"h3","props":{"id":"webpack-in-development"},"children":[{"type":"text","value":"webpack In Development"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Assuming you're using one of the main Vue frameworks, when you start your app in development, it is going to do a few things:"}]},{"type":"element","tag":"ol","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Bundle all of your code"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Start the webpack-dev-server, the Express.js web server which will serve the bundled code"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Setup sockets which will handle the Hot Module Reloading"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"As you may notice with your own apps, the bigger they grow, the longer you have to wait to start coding."}]},{"type":"element","tag":"Image","props":{"alt":"The Nuxt logo is almost burnt into my monitor at this point.","height":549,"src":"/blog/nuxt-start.png","width":789,"sizes":"md:789px sm:95vw xs:95vw"},"children":[]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Bundling in development is quicker because you don't need to do as much with the code, however,\nas your app grows, it will become painfully slow, especially on older machines."}]},{"type":"element","tag":"h3","props":{"id":"webpack-component-example"},"children":[{"type":"text","value":"webpack Component Example"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"I created a default Vue 3 "},{"type":"element","tag":"a","props":{"href":"https://cli.vuejs.org/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Vue CLI"}]},{"type":"text","value":" project, which has an entry "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"App.vue"}]},{"type":"text","value":" file using the "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"HelloWorld.vue"}]},{"type":"text","value":" component.\nLet's see how this component gets to my browser."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"HelloWorld.vue component:"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"vue","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"<script>\nexport default {\n  props: {\n    msg: String\n  }\n}\n</script>\n\n<template>\n  <div class=\"hello\">\n    <h1>{{ msg }}</h1>\n  </div>\n</template>\n\n<style scoped>\nh1 {\n  color: green;\n}\n</style>\n","language":"vue"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"props"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"msg"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"String"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"div"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"class"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"hello"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"h"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"1>{{ "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"msg"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" }}</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"h"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"1>"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  </"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"div"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"style"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"scoped"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"h1"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"color"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" green"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"style"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"When I start my app and visit localhost I get the following HTML from the Express.js server."}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"html","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"utf-8\">\n    <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n    <meta name=\"viewport\" content=\"width=device-width,initial-scale=1.0\">\n  </head>\n  <body>\n    <div id=\"app\"></div>\n    <script type=\"text/javascript\" src=\"/js/chunk-vendors.js\"></script>\n    <script type=\"text/javascript\" src=\"/js/app.js\"></script>\n  </body>\n</html>\n","language":"html"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<!"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"DOCTYPE"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"html"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"html"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"lang"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"en"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"head"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"meta"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"charset"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"utf-8"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"meta"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"http-equiv"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"X-UA-Compatible"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"content"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"IE=edge"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"meta"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"name"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"viewport"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"content"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"width=device-width,initial-scale=1.0"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"head"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"body"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"div"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"id"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"app"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"></"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"div"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"type"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"text/javascript"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"src"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/js/chunk-vendors.js"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"></"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"type"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"text/javascript"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"src"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/js/app.js"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"></"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"body"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"html"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"You'll notice we have 2 script files there: "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"chunk-vendor.js"}]},{"type":"text","value":" and "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"app.js"}]},{"type":"text","value":". On inspecting them you'd see a lot of gibberish looking code.\nit helps to use the "},{"type":"element","tag":"a","props":{"href":"https://www.npmjs.com/package/webpack-bundle-analyzer","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"webpack-bundle-analyzer"}]},{"type":"text","value":" to see how it works visually."}]},{"type":"element","tag":"h4","props":{"id":"chunk-vendorsjs"},"children":[{"type":"text","value":"chunk-vendors.js"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"These are third-party modules, usually coming from "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"node_modules"}]},{"type":"text","value":". The two main libraries in here are Vue itself and sockjs which is used for HMR."}]},{"type":"element","tag":"Image","props":{"alt":"The two top libraries are Vue.js and Sock.js (For HMR)","height":400,"src":"/blog/vendor-chunk.png","width":775,"max-height":400,"sizes":"md:775px sm:95vw xs:95vw"},"children":[]},{"type":"element","tag":"h4","props":{"id":"appjs"},"children":[{"type":"text","value":"app.js"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"This is all the code for my application. It contains components, assets, etc. You'll notice that for an SFC it splits\nit into multiple modules."}]},{"type":"element","tag":"Image","props":{"alt":"My app is two components, App.vue and HelloWorld.vue","height":450,"src":"/blog/app-chunk.png","width":877,"max-height":450,"sizes":"md:877px sm:95vw xs:95vw"},"children":[]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Taking a quick look at the "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"app.js"}]},{"type":"text","value":" file, we can find some of the "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"HelloWorld"}]},{"type":"text","value":" component code. As you can see in the above image,\nall parts of the SFC are separate modules: the wrapper, CSS, template, js."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The wrapper module is defining and importing the other models, some beautiful code."}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"/***/ \"./src/components/HelloWorld.vue\":\n/*!***************************************!*\\\n  !*** ./src/components/HelloWorld.vue ***!\n  \\***************************************/\n/*! exports provided: default */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\neval(\"__webpack_require__.r(__webpack_exports__);\\n/* harmony import */ var _HelloWorld_vue_vue_type_template_id_469af010_scoped_true__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./HelloWorld.vue?vue&type=template&id=469af010&scoped=true */ \\\"./src/components/HelloWorld.vue?vue&type=template&id=469af010&scoped=true\\\");\\n/* harmony import */ var _HelloWorld_vue_vue_type_script_lang_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./HelloWorld.vue?vue&type=script&lang=js */ \\\"./src/components/HelloWorld.vue?vue&type=script&lang=js\\\");\\n/* empty/unused harmony star reexport *//* harmony import */ var _HelloWorld_vue_vue_type_style_index_0_id_469af010_scoped_true_lang_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./HelloWorld.vue?vue&type=style&index=0&id=469af010&scoped=true&lang=css */ \\\"./src/components/HelloWorld.vue?vue&type=style&index=0&id=469af010&scoped=true&lang=css\\\");\\n\\n\\n\\n\\n\\n_HelloWorld_vue_vue_type_script_lang_js__WEBPACK_IMPORTED_MODULE_1__[\\\"default\\\"].render = _HelloWorld_vue_vue_type_template_id_469af010_scoped_true__WEBPACK_IMPORTED_MODULE_0__[\\\"render\\\"]\\n_HelloWorld_vue_vue_type_script_lang_js__WEBPACK_IMPORTED_MODULE_1__[\\\"default\\\"].__scopeId = \\\"data-v-469af010\\\"\\n/* hot reload */\\nif (true) {\\n  _HelloWorld_vue_vue_type_script_lang_js__WEBPACK_IMPORTED_MODULE_1__[\\\"default\\\"].__hmrId = \\\"469af010\\\"\\n  const api = __VUE_HMR_RUNTIME__\\n  module.hot.accept()\\n  if (!api.createRecord('469af010', _HelloWorld_vue_vue_type_script_lang_js__WEBPACK_IMPORTED_MODULE_1__[\\\"default\\\"])) {\\n    api.reload('469af010', _HelloWorld_vue_vue_type_script_lang_js__WEBPACK_IMPORTED_MODULE_1__[\\\"default\\\"])\\n  }\\n  \\n  module.hot.accept(/*! ./HelloWorld.vue?vue&type=template&id=469af010&scoped=true */ \\\"./src/components/HelloWorld.vue?vue&type=template&id=469af010&scoped=true\\\", function(__WEBPACK_OUTDATED_DEPENDENCIES__) { /* harmony import */ _HelloWorld_vue_vue_type_template_id_469af010_scoped_true__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./HelloWorld.vue?vue&type=template&id=469af010&scoped=true */ \\\"./src/components/HelloWorld.vue?vue&type=template&id=469af010&scoped=true\\\");\\n(() => {\\n    api.rerender('469af010', _HelloWorld_vue_vue_type_template_id_469af010_scoped_true__WEBPACK_IMPORTED_MODULE_0__[\\\"render\\\"])\\n  })(__WEBPACK_OUTDATED_DEPENDENCIES__); }.bind(this))\\n\\n}\\n\\n_HelloWorld_vue_vue_type_script_lang_js__WEBPACK_IMPORTED_MODULE_1__[\\\"default\\\"].__file = \\\"src/components/HelloWorld.vue\\\"\\n\\n/* harmony default export */ __webpack_exports__[\\\"default\\\"] = (_HelloWorld_vue_vue_type_script_lang_js__WEBPACK_IMPORTED_MODULE_1__[\\\"default\\\"]);\");\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"/***/"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"./src/components/HelloWorld.vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":":"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"/*!***************************************!*\\"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"  !*** ./src/components/HelloWorld.vue ***!"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"  \\***************************************/"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"/*! exports provided: default */"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"/***/"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"module"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" __webpack_exports__"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" __webpack_require__"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"use strict"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"eval"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"__webpack_require__.r(__webpack_exports__);"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/* harmony import */ var _HelloWorld_vue_vue_type_template_id_469af010_scoped_true__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./HelloWorld.vue?vue&type=template&id=469af010&scoped=true */ "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"./src/components/HelloWorld.vue?vue&type=template&id=469af010&scoped=true"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":");"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/* harmony import */ var _HelloWorld_vue_vue_type_script_lang_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./HelloWorld.vue?vue&type=script&lang=js */ "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"./src/components/HelloWorld.vue?vue&type=script&lang=js"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":");"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/* empty/unused harmony star reexport *//* harmony import */ var _HelloWorld_vue_vue_type_style_index_0_id_469af010_scoped_true_lang_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./HelloWorld.vue?vue&type=style&index=0&id=469af010&scoped=true&lang=css */ "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"./src/components/HelloWorld.vue?vue&type=style&index=0&id=469af010&scoped=true&lang=css"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":");"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n\\n\\n\\n\\n\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"_HelloWorld_vue_vue_type_script_lang_js__WEBPACK_IMPORTED_MODULE_1__["}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"].render = _HelloWorld_vue_vue_type_template_id_469af010_scoped_true__WEBPACK_IMPORTED_MODULE_0__["}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"render"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"_HelloWorld_vue_vue_type_script_lang_js__WEBPACK_IMPORTED_MODULE_1__["}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"].__scopeId = "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"data-v-469af010"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/* hot reload */"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"if (true) {"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"  _HelloWorld_vue_vue_type_script_lang_js__WEBPACK_IMPORTED_MODULE_1__["}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"].__hmrId = "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"469af010"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"  const api = __VUE_HMR_RUNTIME__"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"  module.hot.accept()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"  if (!api.createRecord('469af010', _HelloWorld_vue_vue_type_script_lang_js__WEBPACK_IMPORTED_MODULE_1__["}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"])) {"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"    api.reload('469af010', _HelloWorld_vue_vue_type_script_lang_js__WEBPACK_IMPORTED_MODULE_1__["}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"])"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"  }"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"  module.hot.accept(/*! ./HelloWorld.vue?vue&type=template&id=469af010&scoped=true */ "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"./src/components/HelloWorld.vue?vue&type=template&id=469af010&scoped=true"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":", function(__WEBPACK_OUTDATED_DEPENDENCIES__) { /* harmony import */ _HelloWorld_vue_vue_type_template_id_469af010_scoped_true__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./HelloWorld.vue?vue&type=template&id=469af010&scoped=true */ "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"./src/components/HelloWorld.vue?vue&type=template&id=469af010&scoped=true"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":");"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"(() => {"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"    api.rerender('469af010', _HelloWorld_vue_vue_type_template_id_469af010_scoped_true__WEBPACK_IMPORTED_MODULE_0__["}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"render"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"])"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"  })(__WEBPACK_OUTDATED_DEPENDENCIES__); }.bind(this))"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"_HelloWorld_vue_vue_type_script_lang_js__WEBPACK_IMPORTED_MODULE_1__["}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"].__file = "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"src/components/HelloWorld.vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\"\\n\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/* harmony default export */ __webpack_exports__["}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"] = (_HelloWorld_vue_vue_type_script_lang_js__WEBPACK_IMPORTED_MODULE_1__["}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"]);"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The main takeaway here is that within the "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"app.js"}]},{"type":"text","value":" file contains all modules for my app."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"webpack does let you chunk the bundles how you like, for Nuxt.js it chunks routes individually. The more chunks though,\nthe more requests and more potential blocking js."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"You may see the problem here, we have multiple monolith files that need to be generated anytime we want to use our app.\nWhen we change a file for HMR, we need to regenerate the entire file."}]},{"type":"element","tag":"h2","props":{"id":"understanding-vite"},"children":[{"type":"text","value":"Understanding Vite"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Vite doesn't set out to be a new bundler. Rather, it's a pre-configured build environment using the Rollup\nbundler and a tool for local development."}]},{"type":"element","tag":"h3","props":{"id":"vite-in-development"},"children":[{"type":"text","value":"Vite In Development"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Vite makes the assumption that developers are going to be using the latest browser versions, so it can safely rely on the\nlatest JS functionality straight from the browser - in other words, no babel transpiling!"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"When you start Vite for the first time pre-optimisations will be done on your "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"node_modules"}]},{"type":"text","value":", then "},{"type":"element","tag":"a","props":{"href":"https://github.com/koajs/koa","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Koa"}]},{"type":"text","value":",\na light-weight node web server starts to serve your app."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"There is no bundling or compiling needed to start the dev server, so it's damn quick (< 300ms)."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"When you open your Vite app you'll be served the "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"index.html"}]},{"type":"text","value":" from the server. The browser is going to read the "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"index.html"}]},{"type":"text","value":"\nand know how to parse the Native-ES-Module code."}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"html","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"<script type=\"module\">import \"/vite/client\"</script>\n<div id=\"app\"></div>\n<script type=\"module\" src=\"/@app/index.js\"></script>\n","language":"html"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"type"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"module"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/vite/client"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"</script>"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"div"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"id"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"app"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"></"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"div"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"type"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"module"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"src"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/@app/index.js"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"></"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Parsing the Native-ES-Module means it will read the "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"export"}]},{"type":"text","value":" and "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" lines from your code. It will convert those\nlines into HTTP requests back to the server, where it will again read the "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"export"}]},{"type":"text","value":" and "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" lines and make new requests."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"It will keep going through like this with your dependencies recursively, in a waterfall process, until everything has been resolved."}]},{"type":"element","tag":"Image","props":{"alt":"Recursive network requests triggered from the entry - VitePress.","height":450,"src":"/blog/network-requests.png","width":787,"max-height":450,"sizes":"md:787px sm:95vw xs:95vw"},"children":[]},{"type":"element","tag":"h3","props":{"id":"vite-component-example"},"children":[{"type":"text","value":"Vite Component Example"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Let's take a look at how these requests are working in the browser. After I open my app at "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"http://localhost:3000"}]},{"type":"text","value":", the browser has fetched the following "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"index.js"}]},{"type":"text","value":" file from the web server:"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"import '/@theme/styles/main.scss?import';\nimport Layout from '/@theme/Layout.vue';\nimport NotFound from '/@theme/NotFound.vue';\nimport CardPost from '/@theme/components/CardPost.vue';\n\nconst theme = {\n    Layout,\n    NotFound,\n    enhanceApp({ app, }) {\n        app.component('CardPost', CardPost)\n    }\n};\nexport default theme;\n","highlights":[5],"language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/@theme/styles/main.scss?import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" Layout "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/@theme/Layout.vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" NotFound "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/@theme/NotFound.vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" CardPost "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/@theme/components/CardPost.vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line highlight"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" theme "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    Layout"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    NotFound"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"enhanceApp"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"({"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" app"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"})"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"app"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"component"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"CardPost"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"CardPost"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"};"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" theme"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]}]}]}]}]},{"type":"element","tag":"tip","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Normally, in webpack, you would have to transpile this code to something legacy browsers can understand. Newer browsers know what to do with it, see "},{"type":"element","tag":"a","props":{"href":"https://caniuse.com/es6-module-dynamic-import","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"es6 module dynamic import"}]},{"type":"text","value":"."}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Let's drill into that highlighted line which is requesting the CardPost SFC. The browser will turn that import into a request for "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"http://localhost:3000/@theme/components/CardPost.vue"}]},{"type":"text","value":"."}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"vue","class":"code-block code-block--with-filename"},"children":[{"type":"element","tag":"span","props":{},"children":[{"type":"text","value":"CardPost.vue"}]},{"type":"element","tag":"code","props":{"code":"<script>\nimport posts from '../../posts'\n\nexport default {\n  props: {\n    postIndex: {\n      type: Number,\n      required: true,\n    }\n  },\n  computed: {\n    post() {\n      return posts[this.postIndex]\n    }\n  }\n}\n</script>\n\n<template>\n  <div class=\"card-post\">\n    ...\n  </div>\n</template>\n\n<style lang=\"scss\" scoped>\n.card-post {\n  ...\n}\n</style>\n","filename":"CardPost.vue","language":"vue"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" posts "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"../../posts"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"props"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"postIndex"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"type"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Number"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"required"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"true"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"computed"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"post"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"posts"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"["}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"postIndex"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"]"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"div"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"class"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"card-post"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    ..."}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  </"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"div"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"style"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"lang"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"scss"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"scoped"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"card-post"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" {"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  ..."}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"style"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Once the web server gets this request, it will need to compile the "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"CardPost.vue"}]},{"type":"text","value":" file to javascript and send it back. Vite has many\noptimisations around the Vue compiling so this takes no time."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Let's see what comes through:"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block code-block--with-filename"},"children":[{"type":"element","tag":"span","props":{},"children":[{"type":"text","value":"CardPost.vue - Transpiled"}]},{"type":"element","tag":"code","props":{"code":"import posts from '/.vitepress/posts.ts'\n\nimport '/@theme/components/CardPost.vue?type=style&index=0'\nimport { render as __render } from '/@theme/components/CardPost.vue?type=template'\n\nconst __script = {\n  props: {\n    postIndex: {\n      type: Number,\n      required: true,\n    }\n  },\n  computed: {\n    post() {\n      return posts[this.postIndex]\n    }\n  }\n}\n__script.__scopeId = 'data-v-287b4794'\n__script.render = __render\n__script.__hmrId = '/@theme/components/CardPost.vue'\ntypeof __VUE_HMR_RUNTIME__ !== 'undefined' && __VUE_HMR_RUNTIME__.createRecord(__script.__hmrId, __script)\n__script.__file = '/home/harlan/sites/new.harlanzw.com/app/.vitepress/theme/components/CardPost.vue'\nexport default __script\n","filename":"CardPost.vue - Transpiled","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" posts "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/.vitepress/posts.ts"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/@theme/components/CardPost.vue?type=style&index=0"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"render"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"as"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"__render"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/@theme/components/CardPost.vue?type=template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" __script "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"props"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"postIndex"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"type"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Number"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"required"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"true"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"computed"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"post"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"posts"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"["}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"postIndex"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"]"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"__script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"__scopeId "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"data-v-287b4794"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"__script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"render "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" __render"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"__script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"__hmrId "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/@theme/components/CardPost.vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"typeof"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" __VUE_HMR_RUNTIME__ "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"!=="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"undefined"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"&&"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" __VUE_HMR_RUNTIME__"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"createRecord"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"(__script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"__hmrId"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" __script)"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"__script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"__file "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/home/harlan/sites/new.harlanzw.com/app/.vitepress/theme/components/CardPost.vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" __script"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Cool, so quite a bit going on here. The main thing to note here is how it's split up the SFC into different modules which\nwill need separate requests to fetch. It hasn't bundled these imports into the SFC or some other monolith file."}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Dependencies: "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"/.vitepress/posts.ts"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Template: "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"/@theme/components/CardPost.vue?type=template"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Stylesheet: "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"/@theme/components/CardPost.vue?type=style&index=0"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"If you're curious, this is what the style component response looks like, some nifty for sure."}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"import { updateStyle } from '/vite/client'\nconst css = '.card-post[data-v-287b4794] {\\n  position: relative;\\n}\\n.card-post .prose[data-v-287b4794] {\\n  max-width: 100% !important;\\n}\\n.card-post__link[data-v-287b4794] {\\n  position: absolute;\\n  left: 0;\\n  top: 0;\\n  width: 100%;\\n  height: 100%;\\n  content: \" \";\\n  z-index: 1;\\n}\\n.card-post__content[data-v-287b4794] {\\n  background-color: white;\\n  z-index: 1;\\n}\\n.card-post__effect[data-v-287b4794] {\\n  z-index: -1;\\n  content: \" \";\\n  height: 30px;\\n  width: 100%;\\n  position: absolute;\\n  background-color: #059669;\\n  transition: 0.2s;\\n  opacity: 0;\\n  top: 30px;\\n}\\n.card-post:hover .card-post__effect[data-v-287b4794] {\\n  top: -5px;\\n  opacity: 1;\\n  transform: rotate(0.25deg);\\n}'\nupdateStyle('287b4794-0', css)\nexport default css\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"updateStyle"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/vite/client"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" css "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":".card-post[data-v-287b4794] {"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"  position: relative;"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":".card-post .prose[data-v-287b4794] {"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"  max-width: 100% !important;"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":".card-post__link[data-v-287b4794] {"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"  position: absolute;"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"  left: 0;"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"  top: 0;"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"  width: 100%;"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"  height: 100%;"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"  content: \" \";"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"  z-index: 1;"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":".card-post__content[data-v-287b4794] {"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"  background-color: white;"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"  z-index: 1;"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":".card-post__effect[data-v-287b4794] {"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"  z-index: -1;"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"  content: \" \";"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"  height: 30px;"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"  width: 100%;"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"  position: absolute;"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"  background-color: #059669;"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"  transition: 0.2s;"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"  opacity: 0;"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"  top: 30px;"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":".card-post:hover .card-post__effect[data-v-287b4794] {"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"  top: -5px;"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"  opacity: 1;"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"  transform: rotate(0.25deg);"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"updateStyle"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"287b4794-0"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" css)"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" css"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"You can see how the above allows the Hot Module Replacement to work efficiently. When you have a module that is changed,\nsay the styles within a component, instead of reloading the entire component tree, only the style module needs to be replaced."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"You can also imagine with the above, where Vite slows down. Imagine hundreds of HTTP requests which rely on nested HTTP requests, recursively.\nFortunately, there are optimisation to avoid this situation after the first load. The server will return a 304\nUnmodified HTTP Status code for modules which haven't changed, meaning they will use the browser's cached version of the file."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Vite scales well for any app size because it only needs to request the modules for the route you're on."}]},{"type":"element","tag":"h2","props":{"id":"production-builds"},"children":[{"type":"text","value":"Production Builds"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Since Vite is using Rollup, pre-configured, you'd expect a similar output from Vite as webpack. Vite does boast a quicker\nbuilder and potentially a smaller artifact size, as Rollup is a more efficient bundler than webpack."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The main gotcha is that Vite can still only support ES Modules in the production build, meaning you can't have any dependencies\nwhich don't have ES Module exports."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Vite is also pre-configured to handle your build as a universal app. A universal app is built using a client (virtual browser)\nand a server (node). Allowing it to pre-render the HTML pages, so robot crawlers can fetch your page content without executing\njs and speeding up the initial load for users. That means SEO friendly static sites out of the box 🎉."}]},{"type":"element","tag":"h2","props":{"id":"summary"},"children":[{"type":"text","value":"Summary"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"While I haven't touched on a lot of the complexities of Vite and webpack, I've tried to show you the main difference, how\nbundling and no-bundling look in action."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Hopefully you've seen why Vite is promising alternative. There is so much potential in the ecosystem at the moment, watch this space, given 12-months we could see an explosion of Vite related projects."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"If you want to find out more about Vite, I'd watch Evan's talk on "},{"type":"element","tag":"a","props":{"href":"https://www.youtube.com/watch?v=xXrhg26VCSc&","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Vite & VitePress"}]},{"type":"text","value":"."}]},{"type":"element","tag":"h2","props":{"id":"getting-started-with-vite"},"children":[{"type":"text","value":"Getting started with Vite"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"I'd recommend just spinning up bare-bones Vite to get a feel for it. It's really easy, takes less than a minute."}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"shell","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"npm init vite-app\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"npm init vite-app"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Once you are sold, it's worth checking out "},{"type":"element","tag":"a","props":{"href":"https://github.com/vitejs/awesome-vite","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"the ecosystem"}]},{"type":"text","value":" before you build."}]},{"type":"element","tag":"h3","props":{"id":"recommendations"},"children":[{"type":"text","value":"Recommendations"}]},{"type":"element","tag":"tip","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"You shouldn't be looking to replace Vue CLI or webpack with Vite for existing projects yet, but it may be valuable to check out for new smaller scoped projects."}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The Vite ecosystem isn't that mature yet, the two main projects I'd recommend checking out are "},{"type":"element","tag":"a","props":{"href":"https://vitepress.vuejs.org/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"VitePress"}]},{"type":"text","value":" and "},{"type":"element","tag":"a","props":{"href":"https://github.com/antfu/vitesse","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Vitesse"}]},{"type":"text","value":"."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"If you are in need of a documentation site then VitePress is awesome, you can follow the VuePress documentation to fill in any gaps. VitePress abstracts away\nthe Vite configuration, which will be limiting for non-documentation sites."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Otherwise, I'd choose Vitesse as it's going to give you more flexible on customising your app. Vitesse offers a pre-configured "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vite.config.js"}]},{"type":"text","value":", so you can easily\nstrip anything out you don't need to add whatever you'd like to it."}]}],"toc":{"title":"","searchDepth":2,"depth":2,"links":[{"id":"a-recap-on-vite","depth":2,"text":"A Recap on Vite","children":[{"id":"speed-example","depth":3,"text":"Speed Example"}]},{"id":"vite-vs-webpack","depth":2,"text":"Vite vs webpack","children":[{"id":"webpack-nuxtjs--vue-cli--etc","depth":3,"text":"webpack (Nuxt.js / Vue CLI / etc)"},{"id":"vite","depth":3,"text":"Vite"}]},{"id":"understanding-webpack","depth":2,"text":"Understanding webpack","children":[{"id":"webpack-in-development","depth":3,"text":"webpack In Development"},{"id":"webpack-component-example","depth":3,"text":"webpack Component Example"}]},{"id":"understanding-vite","depth":2,"text":"Understanding Vite","children":[{"id":"vite-in-development","depth":3,"text":"Vite In Development"},{"id":"vite-component-example","depth":3,"text":"Vite Component Example"}]},{"id":"production-builds","depth":2,"text":"Production Builds"},{"id":"summary","depth":2,"text":"Summary"},{"id":"getting-started-with-vite","depth":2,"text":"Getting started with Vite","children":[{"id":"recommendations","depth":3,"text":"Recommendations"}]}]}},"_type":"markdown","_id":"content:posts:how-the-heck-does-vite-work.md","_source":"content","_file":"posts/how-the-heck-does-vite-work.md","_extension":"md","storageMeta":{"atime":"2023-06-16T10:26:05.626Z","mtime":"2023-06-16T10:26:05.626Z","size":19045},"readingMins":8,"path":"/blog/how-the-heck-does-vite-work","renderer":"post","schemaOrg":{"modifiedAt":"2023-06-16T10:26:05.626Z"},"modifiedAt":"2023-06-16T10:26:05.626Z"},{"_path":"/posts/introduce-anse","_draft":false,"_partial":false,"_empty":false,"title":"Introduce Anse","description":"继 ChatGPT Demo 之后又一作品","excerpt":{"type":"root","children":[{"type":"element","tag":"toc","props":{},"children":[]},{"type":"element","tag":"h2","props":{"id":"what-is-anse"},"children":[{"type":"text","value":"What is Anse?"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Anse is a fully optimized UI for AI Chats. Last time we wrote "},{"type":"element","tag":"a","props":{"href":"https://github.com/anse-app/chatgpt-demo","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"ChatGPT-demo"}]},{"type":"text","value":" , Its Github Stars has exceeded 7K +, this time we bring a new work, Anse is a fully optimized UI that supports multiple AI platforms, including "},{"type":"element","tag":"a","props":{"href":"https://openai.com/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"OpenAI"}]},{"type":"text","value":", "},{"type":"element","tag":"a","props":{"href":"https://replicate.com/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Replicate"}]},{"type":"text","value":", etc., but also supports custom model parameters."}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"🍿 "},{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"Live preview"}]},{"type":"text","value":": "},{"type":"element","tag":"a","props":{"href":"https://anse.app","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"https://anse.app"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"📖 "},{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"Documentation"}]},{"type":"text","value":": "},{"type":"element","tag":"a","props":{"href":"https://docs.anse.app","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"https://docs.anse.app"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"✨ "},{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"Release Notes"}]},{"type":"text","value":": "},{"type":"element","tag":"a","props":{"href":"https://github.com/anse-app/anse/releases","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"https://github.com/anse-app/anse/releases"}]}]}]},{"type":"element","tag":"h2","props":{"id":"screenshots"},"children":[{"type":"text","value":"Screenshots"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","src":"https://cdn.staticaly.com/gh/yzh990918/static@master/20230518/image.59m8av303gcg.png"},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","src":"https://cdn.staticaly.com/gh/yzh990918/static@master/20230518/image.4gwy6cm2neyo.webp"},"children":[]}]},{"type":"element","tag":"h2","props":{"id":"features"},"children":[{"type":"text","value":"Features"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"🚀 Powerful Plugin System"}]},{"type":"text","value":" - Powered by "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Provider plugin"}]},{"type":"text","value":" , easy to extend AI platforms such as "},{"type":"element","tag":"a","props":{"href":"https://openai.com/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"OpenAI"}]},{"type":"text","value":", "},{"type":"element","tag":"a","props":{"href":"https://replicate.com/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Replicate"}]},{"type":"text","value":", and also supports custom model parameters."}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"💬 Session Record Saving"}]},{"type":"text","value":" - We use "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"IndexDB"}]},{"type":"text","value":" to store local data, it will not be uploaded to the server, security issues are guaranteed."}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"🎉 Multiple Session Modes"}]},{"type":"text","value":" - Provides different conversations modes，support "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Single Conversation"}]},{"type":"text","value":", "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Continuous Conversation"}]},{"type":"text","value":", "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"OpenAI Image Generation"}]},{"type":"text","value":"、"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Stable Diffusion"}]},{"type":"text","value":" and more."}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"💎 Improved UI Experience"}]},{"type":"text","value":" - We have refactored the website UI for the previous version, optimized a lot of details, and also adapted to "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"mobile end"}]},{"type":"text","value":" and "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"dark mode"}]},{"type":"text","value":"."}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"🌈 One-Click Deployment"}]},{"type":"text","value":" - Support one-click deployment, abandoned use environment variables, you can refer to our documentation to deploy the website to "},{"type":"element","tag":"a","props":{"href":"https://vercel.com/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Vercel"}]},{"type":"text","value":", "},{"type":"element","tag":"a","props":{"href":"https://www.netlify.com/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Netlify"}]},{"type":"text","value":", "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Docker"}]},{"type":"text","value":", "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Node"}]},{"type":"text","value":" and other platforms."}]}]},{"type":"element","tag":"h2","props":{"id":"learn-more"},"children":[{"type":"text","value":"Learn More"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Read the "},{"type":"element","tag":"a","props":{"href":"https://docs.anse.app","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"documentation"}]},{"type":"text","value":" for more information."}]}]},"publishedAt":"2023-05-18","status":"published","body":{"type":"root","children":[{"type":"element","tag":"toc","props":{},"children":[]},{"type":"element","tag":"h2","props":{"id":"what-is-anse"},"children":[{"type":"text","value":"What is Anse?"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Anse is a fully optimized UI for AI Chats. Last time we wrote "},{"type":"element","tag":"a","props":{"href":"https://github.com/anse-app/chatgpt-demo","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"ChatGPT-demo"}]},{"type":"text","value":" , Its Github Stars has exceeded 7K +, this time we bring a new work, Anse is a fully optimized UI that supports multiple AI platforms, including "},{"type":"element","tag":"a","props":{"href":"https://openai.com/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"OpenAI"}]},{"type":"text","value":", "},{"type":"element","tag":"a","props":{"href":"https://replicate.com/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Replicate"}]},{"type":"text","value":", etc., but also supports custom model parameters."}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"🍿 "},{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"Live preview"}]},{"type":"text","value":": "},{"type":"element","tag":"a","props":{"href":"https://anse.app","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"https://anse.app"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"📖 "},{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"Documentation"}]},{"type":"text","value":": "},{"type":"element","tag":"a","props":{"href":"https://docs.anse.app","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"https://docs.anse.app"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"✨ "},{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"Release Notes"}]},{"type":"text","value":": "},{"type":"element","tag":"a","props":{"href":"https://github.com/anse-app/anse/releases","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"https://github.com/anse-app/anse/releases"}]}]}]},{"type":"element","tag":"h2","props":{"id":"screenshots"},"children":[{"type":"text","value":"Screenshots"}]},{"type":"element","tag":"Image","props":{"alt":"","src":"https://cdn.staticaly.com/gh/yzh990918/static@master/20230518/image.59m8av303gcg.png"},"children":[]},{"type":"element","tag":"Image","props":{"alt":"","src":"https://cdn.staticaly.com/gh/yzh990918/static@master/20230518/image.4gwy6cm2neyo.webp"},"children":[]},{"type":"element","tag":"h2","props":{"id":"features"},"children":[{"type":"text","value":"Features"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"🚀 Powerful Plugin System"}]},{"type":"text","value":" - Powered by "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Provider plugin"}]},{"type":"text","value":" , easy to extend AI platforms such as "},{"type":"element","tag":"a","props":{"href":"https://openai.com/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"OpenAI"}]},{"type":"text","value":", "},{"type":"element","tag":"a","props":{"href":"https://replicate.com/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Replicate"}]},{"type":"text","value":", and also supports custom model parameters."}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"💬 Session Record Saving"}]},{"type":"text","value":" - We use "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"IndexDB"}]},{"type":"text","value":" to store local data, it will not be uploaded to the server, security issues are guaranteed."}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"🎉 Multiple Session Modes"}]},{"type":"text","value":" - Provides different conversations modes，support "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Single Conversation"}]},{"type":"text","value":", "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Continuous Conversation"}]},{"type":"text","value":", "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"OpenAI Image Generation"}]},{"type":"text","value":"、"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Stable Diffusion"}]},{"type":"text","value":" and more."}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"💎 Improved UI Experience"}]},{"type":"text","value":" - We have refactored the website UI for the previous version, optimized a lot of details, and also adapted to "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"mobile end"}]},{"type":"text","value":" and "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"dark mode"}]},{"type":"text","value":"."}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"🌈 One-Click Deployment"}]},{"type":"text","value":" - Support one-click deployment, abandoned use environment variables, you can refer to our documentation to deploy the website to "},{"type":"element","tag":"a","props":{"href":"https://vercel.com/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Vercel"}]},{"type":"text","value":", "},{"type":"element","tag":"a","props":{"href":"https://www.netlify.com/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Netlify"}]},{"type":"text","value":", "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Docker"}]},{"type":"text","value":", "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Node"}]},{"type":"text","value":" and other platforms."}]}]},{"type":"element","tag":"h2","props":{"id":"learn-more"},"children":[{"type":"text","value":"Learn More"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Read the "},{"type":"element","tag":"a","props":{"href":"https://docs.anse.app","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"documentation"}]},{"type":"text","value":" for more information."}]}],"toc":{"title":"","searchDepth":2,"depth":2,"links":[{"id":"what-is-anse","depth":2,"text":"What is Anse?"},{"id":"screenshots","depth":2,"text":"Screenshots"},{"id":"features","depth":2,"text":"Features"},{"id":"learn-more","depth":2,"text":"Learn More"}]}},"_type":"markdown","_id":"content:posts:introduce-anse.md","_source":"content","_file":"posts/introduce-anse.md","_extension":"md","storageMeta":{"atime":"2023-06-16T10:26:05.626Z","mtime":"2023-06-16T10:26:05.626Z","size":1986},"readingMins":1,"path":"/blog/introduce-anse","renderer":"post","schemaOrg":{"modifiedAt":"2023-06-16T10:26:05.626Z"},"modifiedAt":"2023-06-16T10:26:05.626Z"},{"_path":"/posts/learn-vue-router","_draft":false,"_partial":false,"_empty":false,"title":"vue-router 源码分析","description":"VueRouter 源码解析和应用","excerpt":{"type":"root","children":[{"type":"element","tag":"toc","props":{},"children":[]},{"type":"element","tag":"tip","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"首先阅读源码之前最好是将 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vue-router"}]},{"type":"text","value":" 的源码下载下来，然后第一遍阅读建议先跟着"},{"type":"element","tag":"a","props":{"href":"https://router.vuejs.org/zh/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"官方文档"}]},{"type":"text","value":"先走一遍基础用法。然后第二遍开始阅读源码，首先理清楚各层级目录的作用和抽出一些核心的文件出来，过一遍代码的同时写个小的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"demo"}]},{"type":"text","value":" 边看边打断点调试，看不懂没关系，可以边看边参考一些总结的比较好的文章，最后将整个注册到 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"init"}]},{"type":"text","value":"到生成 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"matcher"}]},{"type":"text","value":" 等等过程根据自己的理解整理出来，然后画一画相关的知识脑图加深印象。"}]}]},{"type":"element","tag":"h2","props":{"id":"前置知识-flow-语法"},"children":[{"type":"text","value":"前置知识: flow 语法"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"\bJS"}]},{"type":"text","value":" 在编译过程中可能看不出一些隐蔽的错误，但在运行过程中会报各种各样的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"bug"}]},{"type":"text","value":"。"},{"type":"element","tag":"a","props":{"href":"https://flow.org/en/docs/getting-started/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Flow"}]},{"type":"text","value":" 的作用就是编译期间进行静态类型检查，尽早发现错误，抛出异常。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue"}]},{"type":"text","value":" 、"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue-router"}]},{"type":"text","value":" 等大型项目往往需要这种工具去做静态类型检查以保证代码的可维护性和可靠性。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"使用 Flow"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"首先在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"index.js"}]},{"type":"text","value":" 文件中输入以下代码"}]},{"type":"element","tag":"code","props":{"code":"// @flow\nfunction foo(x: ?number): string {\n  if (x) {\n    return x;\n  }\n  return \"default string\";\n}\n\nfoo(\"hello\")\n\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"// @flow\nfunction foo(x: ?number): string {\n  if (x) {\n    return x;\n  }\n  return \"default string\";\n}\n\nfoo(\"hello\")\n\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"然后安装 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"flow"}]},{"type":"text","value":",并初始化 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".flowconfig"}]}]},{"type":"element","tag":"code","props":{"code":"npm install flow-bin -g\n\ncd test\n\nflow init\n\nflow\n","language":"bash"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"npm install flow-bin -g\n\ncd test\n\nflow init\n\nflow\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"这个时候不出意外就会抛出异常提示，这就是简单的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"flow"}]},{"type":"text","value":" 使用方法。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"定义不同类型的类型声明"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"字符串:"}]},{"type":"element","tag":"code","props":{"code":"// @flow\nfunction concat(a: string, b: string) {\n  return a + b;\n}\n\nconcat(\"A\", \"B\"); // Works!\nconcat(1, 2); // Error!\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"// @flow\nfunction concat(a: string, b: string) {\n  return a + b;\n}\n\nconcat(\"A\", \"B\"); // Works!\nconcat(1, 2); // Error!\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"boolean:"}]},{"type":"element","tag":"code","props":{"code":"// @flow\nfunction acceptsBoolean(value: boolean) {\n  // ...\n}\n\nacceptsBoolean(true);  // Works!\nacceptsBoolean(false); // Works!\nacceptsBoolean(\"foo\"); // Error!\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"// @flow\nfunction acceptsBoolean(value: boolean) {\n  // ...\n}\n\nacceptsBoolean(true);  // Works!\nacceptsBoolean(false); // Works!\nacceptsBoolean(\"foo\"); // Error!\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"number + 设置默认值 :"}]},{"type":"element","tag":"code","props":{"code":"// @flow\nfunction concat(a: number = 1, b: number) {\n  return a + b;\n}\n\nconcat(\"A\", \"B\"); // Error!\nconcat(1, 2); // Works!\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"// @flow\nfunction concat(a: number = 1, b: number) {\n  return a + b;\n}\n\nconcat(\"A\", \"B\"); // Error!\nconcat(1, 2); // Works!\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"null 或者 undefined(void处理):"}]},{"type":"element","tag":"code","props":{"code":"// @flow\nfunction acceptsNull(value: null) {\n  /* ... */\n}\n\nfunction acceptsUndefined(value: void) {\n  /* ... */\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"// @flow\nfunction acceptsNull(value: null) {\n  /* ... */\n}\n\nfunction acceptsUndefined(value: void) {\n  /* ... */\n}\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"动态类型:"}]},{"type":"element","tag":"code","props":{"code":"// @flow\nfunction acceptsMaybeString(value: ?string) {\n  // value可能为值类型的某一个\n}\n\n// @flow\nfunction acceptNumberOrString(value: string | number){\n\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"// @flow\nfunction acceptsMaybeString(value: ?string) {\n  // value可能为值类型的某一个\n}\n\n// @flow\nfunction acceptNumberOrString(value: string | number){\n\n}\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"数组:"}]},{"type":"element","tag":"code","props":{"code":" // @flow\n function acceptArray(value: Array<number>) {\n\n }\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":" // @flow\n function acceptArray(value: Array<number>) {\n\n }\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"对象:"}]},{"type":"element","tag":"code","props":{"code":" // @flow\n function acceptObject(value: obj){\n\n }\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":" // @flow\n function acceptObject(value: obj){\n\n }\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"另外还支持自定义类型等等，具体用法还需要参考 "},{"type":"element","tag":"a","props":{"href":"https://flow.org/en/docs/types/primitives/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"flow官网"}]}]},{"type":"element","tag":"h2","props":{"id":"注册"},"children":[{"type":"text","value":"注册"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"我们平时在使用 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue-Router"}]},{"type":"text","value":" 的时候通常需要在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"main.js"}]},{"type":"text","value":" 中初始化 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue"}]},{"type":"text","value":" 实例时将 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vue-router"}]},{"type":"text","value":" 实例对象当做参数传入"}]},{"type":"element","tag":"code","props":{"code":"import Router from 'vue-router'\nVue.use(Router)\n\nconst routes = [\n  {\n    path: \"/\",\n    component: goods\n  },\n  {\n    path: \"/comment\",\n    name: \"comment\",\n    component: comment\n  },\n  {\n    path: \"/seller\",\n    name: \"seller\",\n    component: seller\n  }\n];\n\nconst router = new Router({\n  mode: \"history\",\n  linkActiveClass: \"active\",\n  //   指定点击后的样式名\n  base: process.env.BASE_URL,\n  routes\n});\n\nnew Vue({\n    router,\n    store,\n    render: h => h(App)\n}).$mount(\"#app\");\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import Router from 'vue-router'\nVue.use(Router)\n\nconst routes = [\n  {\n    path: \"/\",\n    component: goods\n  },\n  {\n    path: \"/comment\",\n    name: \"comment\",\n    component: comment\n  },\n  {\n    path: \"/seller\",\n    name: \"seller\",\n    component: seller\n  }\n];\n\nconst router = new Router({\n  mode: \"history\",\n  linkActiveClass: \"active\",\n  //   指定点击后的样式名\n  base: process.env.BASE_URL,\n  routes\n});\n\nnew Vue({\n    router,\n    store,\n    render: h => h(App)\n}).$mount(\"#app\");\n"}]}]}]},{"type":"element","tag":"h2","props":{"id":"vueuse"},"children":[{"type":"text","value":"Vue.use"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"那么 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue.use(Router)"}]},{"type":"text","value":" 又在做什么事情呢"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"问题定位到 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue"}]},{"type":"text","value":" 源码中的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"src/core/global-api/use.js"}]}]},{"type":"element","tag":"code","props":{"code":"export function initUse (Vue: GlobalAPI) {\n  Vue.use = function (plugin: Function | Object) {\n    // 拿到installPlugins \n    const installedPlugins = (this._installedPlugins || (this._installedPlugins = []))\n    // 保证不会重复注册\n    if (installedPlugins.indexOf(plugin) > -1) {\n      return this\n    }\n\n    // 获取第一个参数plugins意外的参数\n    const args = toArray(arguments, 1)\n    // 将Vue实例添加到参数\n    args.unshift(this)\n    // 执行plugin的install方法 每个insatll方法的第一个参数都会变成Vue，不需要额外引入\n    if (typeof plugin.install === 'function') {\n      plugin.install.apply(plugin, args)\n    } else if (typeof plugin === 'function') {\n      plugin.apply(null, args)\n    }\n    // 最后将installPlugins保存 \n    installedPlugins.push(plugin)\n    return this\n  }\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"export function initUse (Vue: GlobalAPI) {\n  Vue.use = function (plugin: Function | Object) {\n    // 拿到installPlugins \n    const installedPlugins = (this._installedPlugins || (this._installedPlugins = []))\n    // 保证不会重复注册\n    if (installedPlugins.indexOf(plugin) > -1) {\n      return this\n    }\n\n    // 获取第一个参数plugins意外的参数\n    const args = toArray(arguments, 1)\n    // 将Vue实例添加到参数\n    args.unshift(this)\n    // 执行plugin的install方法 每个insatll方法的第一个参数都会变成Vue，不需要额外引入\n    if (typeof plugin.install === 'function') {\n      plugin.install.apply(plugin, args)\n    } else if (typeof plugin === 'function') {\n      plugin.apply(null, args)\n    }\n    // 最后将installPlugins保存 \n    installedPlugins.push(plugin)\n    return this\n  }\n}\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"可以看到 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue"}]},{"type":"text","value":" 的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"use"}]},{"type":"text","value":" 方法会接受一个 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"plugin"}]},{"type":"text","value":" 参数，然后使用 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"installPlugins"}]},{"type":"text","value":"数组 保存已经注册过的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"plugin"}]},{"type":"text","value":" 。 首先保证 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"plugin"}]},{"type":"text","value":" 不被重复注册，然后将 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue"}]},{"type":"text","value":" 从函数参数中取出，将整个 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue"}]},{"type":"text","value":" 作为 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"plugin"}]},{"type":"text","value":"的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" 方法的第一个参数，这样做的好处就是不需要麻烦的另外引入 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue"}]},{"type":"text","value":" ,便于操作, 接着就去判断 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"plugin"}]},{"type":"text","value":" 上是否存在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" 方法。存在则将赋值后的参数传入执行 ，最后将所有的存在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" 方法的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"plugin"}]},{"type":"text","value":" 交给 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"installPlugins"}]},{"type":"text","value":" 维护。"}]},{"type":"element","tag":"h2","props":{"id":"install"},"children":[{"type":"text","value":"install"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"了解清楚 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue.use"}]},{"type":"text","value":" 的结构之后，可以得出 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue"}]},{"type":"text","value":" 注册插件其实就是在执行插件的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" 方法，参数的第一项就是"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue"}]},{"type":"text","value":",所以我们将代码定位到 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vue-router"}]},{"type":"text","value":" 源码中的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"src/install.js"}]}]},{"type":"element","tag":"code","props":{"code":"// 保存Vue的局部变量\nexport let _Vue\n\nexport function install (Vue) {\n  // 如果已安装\n  if (install.installed && _Vue === Vue) return\n  install.installed = true\n // 局部变量保留传入的Vue\n  _Vue = Vue\n\n  const isDef = v => v !== undefined\n\n  const registerInstance = (vm, callVal) => {\n    let i = vm.$options._parentVnode\n    if (isDef(i) && isDef(i = i.data) && isDef(i = i.registerRouteInstance)) {\n      i(vm, callVal)\n    }\n  }\n\n  // 全局混入钩子函数 每个组件都会有这些钩子函数，执行就会走这里的逻辑\n  Vue.mixin({\n    beforeCreate () {\n      if (isDef(this.$options.router)) {\n        // new Vue时传入的根组件router router对象传入时就可以拿到this.$options.router\n        // 跟router\n        this._routerRoot = this\n        this._router = this.$options.router\n        this._router.init(this)\n        // 变成响应式\n        Vue.util.defineReactive(this, '_route', this._router.history.current)\n      } else {\n        // 非根组件访问根组件通过$parent\n        this._routerRoot = (this.$parent && this.$parent._routerRoot) || this\n      }\n      registerInstance(this, this)\n    },\n    destroyed () {\n      registerInstance(this)\n    }\n  })\n\n  // 通过get方法 原型加入$router 和 $route\n  Object.defineProperty(Vue.prototype, '$router', {\n    get () { return this._routerRoot._router }\n  })\n\n  Object.defineProperty(Vue.prototype, '$route', {\n    get () { return this._routerRoot._route }\n  })\n// 全局注册\n  Vue.component('RouterView', View)\n  Vue.component('RouterLink', Link)\n// 获取合并策略\n  const strats = Vue.config.optionMergeStrategies\n  // use the same hook merging strategy for route hooks\n  strats.beforeRouteEnter = strats.beforeRouteLeave = strats.beforeRouteUpdate = strats.created\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"// 保存Vue的局部变量\nexport let _Vue\n\nexport function install (Vue) {\n  // 如果已安装\n  if (install.installed && _Vue === Vue) return\n  install.installed = true\n // 局部变量保留传入的Vue\n  _Vue = Vue\n\n  const isDef = v => v !== undefined\n\n  const registerInstance = (vm, callVal) => {\n    let i = vm.$options._parentVnode\n    if (isDef(i) && isDef(i = i.data) && isDef(i = i.registerRouteInstance)) {\n      i(vm, callVal)\n    }\n  }\n\n  // 全局混入钩子函数 每个组件都会有这些钩子函数，执行就会走这里的逻辑\n  Vue.mixin({\n    beforeCreate () {\n      if (isDef(this.$options.router)) {\n        // new Vue时传入的根组件router router对象传入时就可以拿到this.$options.router\n        // 跟router\n        this._routerRoot = this\n        this._router = this.$options.router\n        this._router.init(this)\n        // 变成响应式\n        Vue.util.defineReactive(this, '_route', this._router.history.current)\n      } else {\n        // 非根组件访问根组件通过$parent\n        this._routerRoot = (this.$parent && this.$parent._routerRoot) || this\n      }\n      registerInstance(this, this)\n    },\n    destroyed () {\n      registerInstance(this)\n    }\n  })\n\n  // 通过get方法 原型加入$router 和 $route\n  Object.defineProperty(Vue.prototype, '$router', {\n    get () { return this._routerRoot._router }\n  })\n\n  Object.defineProperty(Vue.prototype, '$route', {\n    get () { return this._routerRoot._route }\n  })\n// 全局注册\n  Vue.component('RouterView', View)\n  Vue.component('RouterLink', Link)\n// 获取合并策略\n  const strats = Vue.config.optionMergeStrategies\n  // use the same hook merging strategy for route hooks\n  strats.beforeRouteEnter = strats.beforeRouteLeave = strats.beforeRouteUpdate = strats.created\n}\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"可以看到这段代码核心部分就是在执行 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" 方法时使用 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"mixin"}]},{"type":"text","value":" 的方式将每个组件都混入 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"beforeCreate"}]},{"type":"text","value":", "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"destroyed"}]},{"type":"text","value":" 这两个生命周期钩子。在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"beforeCreate"}]},{"type":"text","value":" 函数中会去判断当前传入的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"router"}]},{"type":"text","value":" 实例是否是跟组件，如果是，则将 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"_routerRoot"}]},{"type":"text","value":" 赋值为当前组件实例、"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"_router"}]},{"type":"text","value":" 赋值为传入的"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"VueRouter"}]},{"type":"text","value":" 实例对象，接着执行 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"init"}]},{"type":"text","value":" 方法初始化 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"router"}]},{"type":"text","value":",然后将 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"this_route"}]},{"type":"text","value":" 响应式化。非根组件的话 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"_routerRoot"}]},{"type":"text","value":"  就指向 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"$parent"}]},{"type":"text","value":" 父实例。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"然后执行 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"registerInstance(this,this)"}]},{"type":"text","value":" 方法，该方法后文会分析。原型加入 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"$router"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"$route"}]},{"type":"text","value":" ，最后注册 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"ROuterView"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"RouterLink"}]},{"type":"text","value":"，这就是整个 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"install"}]},{"type":"text","value":"的过程。"}]},{"type":"element","tag":"h2","props":{"id":"总结"},"children":[{"type":"text","value":"总结"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue.use(plugin)"}]},{"type":"text","value":" 实际上在执行 plugin上的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" 方法，"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"insatll"}]},{"type":"text","value":" 方法有个重要的步骤就是使用 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"mixin"}]},{"type":"text","value":" 在组件中混入 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"beforeCreate"}]},{"type":"text","value":" , "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"destory"}]},{"type":"text","value":" 这俩个生命周期钩子，然后在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"beforeCreate"}]},{"type":"text","value":" 这个钩子进行初始化。"}]},{"type":"element","tag":"h2","props":{"id":"vuerouter"},"children":[{"type":"text","value":"vueRouter"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"接着就是这个最重要的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"class"}]},{"type":"text","value":": "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vueRouter"}]},{"type":"text","value":" 。这一部分代码比较多，所以不一一列举，挑重点分析，"},{"type":"element","tag":"a","props":{"href":"https://github.com/vuejs/vue-router/blob/v3.1.2/src/index.js","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"vueRouter源码地址"}]}]},{"type":"element","tag":"h2","props":{"id":"构造函数"},"children":[{"type":"text","value":"构造函数"}]},{"type":"element","tag":"code","props":{"code":"  constructor (options: RouterOptions = {}) {\n    this.app = null\n    this.apps = []\n    this.options = options\n    this.beforeHooks = []\n    this.resolveHooks = []\n    this.afterHooks = []\n    this.matcher = createMatcher(options.routes || [], this)\n\n    // 一般分两种模式 hash和history路由 第三种是抽象模式\n    let mode = options.mode || 'hash'\n    // 判断当前传入的配置是否能使用history模式\n    this.fallback = mode === 'history' && !supportsPushState && options.fallback !== false\n    // 降级处理\n    if (this.fallback) {\n      mode = 'hash'\n    }\n    if (!inBrowser) {\n      mode = 'abstract'\n    }\n    this.mode = mode\n\n    // 根据模式实例化不同的history history对象会对路由进行管理 继承于history class\n    switch (mode) {\n      case 'history':\n        this.history = new HTML5History(this, options.base)\n        break\n      case 'hash':\n        this.history = new HashHistory(this, options.base, this.fallback)\n        break\n      case 'abstract':\n        this.history = new AbstractHistory(this, options.base)\n        break\n      default:\n        if (process.env.NODE_ENV !== 'production') {\n          assert(false, `invalid mode: ${mode}`)\n        }\n    }\n  }\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"  constructor (options: RouterOptions = {}) {\n    this.app = null\n    this.apps = []\n    this.options = options\n    this.beforeHooks = []\n    this.resolveHooks = []\n    this.afterHooks = []\n    this.matcher = createMatcher(options.routes || [], this)\n\n    // 一般分两种模式 hash和history路由 第三种是抽象模式\n    let mode = options.mode || 'hash'\n    // 判断当前传入的配置是否能使用history模式\n    this.fallback = mode === 'history' && !supportsPushState && options.fallback !== false\n    // 降级处理\n    if (this.fallback) {\n      mode = 'hash'\n    }\n    if (!inBrowser) {\n      mode = 'abstract'\n    }\n    this.mode = mode\n\n    // 根据模式实例化不同的history history对象会对路由进行管理 继承于history class\n    switch (mode) {\n      case 'history':\n        this.history = new HTML5History(this, options.base)\n        break\n      case 'hash':\n        this.history = new HashHistory(this, options.base, this.fallback)\n        break\n      case 'abstract':\n        this.history = new AbstractHistory(this, options.base)\n        break\n      default:\n        if (process.env.NODE_ENV !== 'production') {\n          assert(false, `invalid mode: ${mode}`)\n        }\n    }\n  }\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"首先在初始化 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vueRouter"}]},{"type":"text","value":" 整个对象时定义了许多变量，"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"app"}]},{"type":"text","value":" 代表 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue"}]},{"type":"text","value":" 实例，"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"options"}]},{"type":"text","value":" 代表传入的配置参数，然后就是路由拦截有用的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"hooks"}]},{"type":"text","value":"和重要的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"matcher"}]},{"type":"text","value":"(后文会写到)。构造函数其实在做两件事情: 1. 确定当前路由使用的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"mode"}]},{"type":"text","value":"，2. 实例化对应的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"history"}]},{"type":"text","value":"对象。"}]},{"type":"element","tag":"h2","props":{"id":"init"},"children":[{"type":"text","value":"init"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"接着完成实例化 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vueRouter"}]},{"type":"text","value":" 之后，如果这个实例传入后，也就是刚开始说的将 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vueRouter"}]},{"type":"text","value":" 实例在初始化 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue"}]},{"type":"text","value":" 时传入，他会在执行 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"beforeCreate"}]},{"type":"text","value":" 时执行 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"init"}]},{"type":"text","value":" 方法`"}]},{"type":"element","tag":"code","props":{"code":"init (app: any) {\n  process.env.NODE_ENV !== 'production' && assert(\n    install.installed,\n    `not installed. Make sure to call \\`Vue.use(VueRouter)\\` ` +\n    `before creating root instance.`\n  )\n  this.apps.push(app)\n  // 确保后面的逻辑只走一次\n  if (this.app) {\n    return\n  }\n\n  this.app = app\n  const history = this.history\n  if (history instanceof HTML5History) {\n    history.transitionTo(history.getCurrentLocation())\n  } else if (history instanceof HashHistory) {\n    const setupHashListener = () => {\n      history.setupListeners()\n    }\n    history.transitionTo(\n      history.getCurrentLocation(),\n      setupHashListener,\n      setupHashListener\n    )\n  }\n  history.listen(route => {\n    this.apps.forEach((app) => {\n      app._route = route\n    })\n  })\n}\n\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"init (app: any) {\n  process.env.NODE_ENV !== 'production' && assert(\n    install.installed,\n    `not installed. Make sure to call \\`Vue.use(VueRouter)\\` ` +\n    `before creating root instance.`\n  )\n  this.apps.push(app)\n  // 确保后面的逻辑只走一次\n  if (this.app) {\n    return\n  }\n\n  this.app = app\n  const history = this.history\n  if (history instanceof HTML5History) {\n    history.transitionTo(history.getCurrentLocation())\n  } else if (history instanceof HashHistory) {\n    const setupHashListener = () => {\n      history.setupListeners()\n    }\n    history.transitionTo(\n      history.getCurrentLocation(),\n      setupHashListener,\n      setupHashListener\n    )\n  }\n  history.listen(route => {\n    this.apps.forEach((app) => {\n      app._route = route\n    })\n  })\n}\n\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"init"}]},{"type":"text","value":" 方法传入 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue"}]},{"type":"text","value":" 实例，保存到 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"this.apps"}]},{"type":"text","value":" 当中。"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue实例"}]},{"type":"text","value":" 会取出当前的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"this.history"}]},{"type":"text","value":"，如果是哈希路由，先走 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"setupHashListener"}]},{"type":"text","value":" 函数，然后调一个关键的函数 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"transitionTo"}]},{"type":"text","value":" ,这个函数其实调用了 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"this.matcher.match"}]},{"type":"text","value":" 去匹配。"}]},{"type":"element","tag":"h2","props":{"id":"总结-1"},"children":[{"type":"text","value":"总结"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"初始化路由需要传入 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vueRouter"}]},{"type":"text","value":" 实例对象，然后在组件初始化阶段执行 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"beforeCreate"}]},{"type":"text","value":" 钩子，调用 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"init"}]},{"type":"text","value":" 方法，接着拿到 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"this.history"}]},{"type":"text","value":" 去调用 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"transitionTo"}]},{"type":"text","value":" 进行路由过渡。"}]},{"type":"element","tag":"h2","props":{"id":"matcher"},"children":[{"type":"text","value":"matcher"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"之前在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vueRouter"}]},{"type":"text","value":" 的构造函数中初始化了 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"macther"}]},{"type":"text","value":" ,本节将详细分析下面这句代码到底在做什么事情,以及 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"match"}]},{"type":"text","value":" 方法在做什么"}]},{"type":"element","tag":"code","props":{"code":" this.matcher = createMatcher(options.routes || [], this)\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":" this.matcher = createMatcher(options.routes || [], this)\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"首先将代码定位到 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"create-matcher.js"}]}]},{"type":"element","tag":"code","props":{"code":"export function createMatcher (\n  routes: Array<RouteConfig>,\n  router: VueRouter\n): Matcher {\n  // 创建映射表\n  const { pathList, pathMap, nameMap } = createRouteMap(routes)\n\n  function addRoutes(routes){...}\n\n  function match (\n    raw: RawLocation,\n    currentRoute?: Route,\n    redirectedFrom?: Location\n  ): Route {...}\n\n  function redirect (\n    record: RouteRecord,\n    location: Location\n  ): Route {...}\n\n  function alias (\n    record: RouteRecord,\n    location: Location,\n    matchAs: string\n  ): Route {...}\n\n  function _createRoute (\n    record: ?RouteRecord,\n    location: Location,\n    redirectedFrom?: Location\n  ): Route {...}\n\n  function matchRoute (\n    regex: RouteRegExp,\n    path: string,\n    params: Object\n  ): boolean {...}\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"export function createMatcher (\n  routes: Array<RouteConfig>,\n  router: VueRouter\n): Matcher {\n  // 创建映射表\n  const { pathList, pathMap, nameMap } = createRouteMap(routes)\n\n  function addRoutes(routes){...}\n\n  function match (\n    raw: RawLocation,\n    currentRoute?: Route,\n    redirectedFrom?: Location\n  ): Route {...}\n\n  function redirect (\n    record: RouteRecord,\n    location: Location\n  ): Route {...}\n\n  function alias (\n    record: RouteRecord,\n    location: Location,\n    matchAs: string\n  ): Route {...}\n\n  function _createRoute (\n    record: ?RouteRecord,\n    location: Location,\n    redirectedFrom?: Location\n  ): Route {...}\n\n  function matchRoute (\n    regex: RouteRegExp,\n    path: string,\n    params: Object\n  ): boolean {...}\n}\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"createMatcher"}]},{"type":"text","value":" 接受俩参数,分别是 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"routes"}]},{"type":"text","value":" ,这个就是我们平时在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"router.js"}]},{"type":"text","value":" 定义的路由表配置，然后还有一个参数是 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"router"}]},{"type":"text","value":" 他是 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"new vueRouter"}]},{"type":"text","value":" 返回的实例。"}]},{"type":"element","tag":"h2","props":{"id":"create-route-map"},"children":[{"type":"text","value":"create-route-map"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"下面这句代码是在创建一张 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"path-record"}]},{"type":"text","value":","},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"name-record"}]},{"type":"text","value":" 的映射表，我们将代码定位到 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"create-route-map.js"}]}]},{"type":"element","tag":"code","props":{"code":"export function createRouteMap (\n  routes: Array<RouteConfig>,\n  oldPathList?: Array<string>,\n  oldPathMap?: Dictionary<RouteRecord>,\n  oldNameMap?: Dictionary<RouteRecord>\n): {\n  pathList: Array<string>,\n  pathMap: Dictionary<RouteRecord>,\n  nameMap: Dictionary<RouteRecord>\n} {\n  // debugger\n  // 记录所有的 path\n  const pathList: Array<string> = oldPathList || []\n  // 记录 path-RouteRecord 的 Map\n  const pathMap: Dictionary<RouteRecord> = oldPathMap || Object.create(null)\n   // 记录 path-RouteRecord 的 Map\n  const nameMap: Dictionary<RouteRecord> = oldNameMap || Object.create(null)\n  // 遍历所有的 route 生成对应映射表\n  routes.forEach(route => {\n    addRouteRecord(pathList, pathMap, nameMap, route)\n  })\n  // 调整优先级\n  for (let i = 0, l = pathList.length; i < l; i++) {\n    if (pathList[i] === '*') {\n      pathList.push(pathList.splice(i, 1)[0])\n      l--\n      i--\n    }\n  }\n\n  return {\n    pathList,\n    pathMap,\n    nameMap\n  }\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"export function createRouteMap (\n  routes: Array<RouteConfig>,\n  oldPathList?: Array<string>,\n  oldPathMap?: Dictionary<RouteRecord>,\n  oldNameMap?: Dictionary<RouteRecord>\n): {\n  pathList: Array<string>,\n  pathMap: Dictionary<RouteRecord>,\n  nameMap: Dictionary<RouteRecord>\n} {\n  // debugger\n  // 记录所有的 path\n  const pathList: Array<string> = oldPathList || []\n  // 记录 path-RouteRecord 的 Map\n  const pathMap: Dictionary<RouteRecord> = oldPathMap || Object.create(null)\n   // 记录 path-RouteRecord 的 Map\n  const nameMap: Dictionary<RouteRecord> = oldNameMap || Object.create(null)\n  // 遍历所有的 route 生成对应映射表\n  routes.forEach(route => {\n    addRouteRecord(pathList, pathMap, nameMap, route)\n  })\n  // 调整优先级\n  for (let i = 0, l = pathList.length; i < l; i++) {\n    if (pathList[i] === '*') {\n      pathList.push(pathList.splice(i, 1)[0])\n      l--\n      i--\n    }\n  }\n\n  return {\n    pathList,\n    pathMap,\n    nameMap\n  }\n}\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"createRouteMap"}]},{"type":"text","value":" 需要传入路由配置，支持传入旧路径数组和旧的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Map"}]},{"type":"text","value":"这一步是为后面递归和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"addRoutes"}]},{"type":"text","value":" 做好准备。 首先用三个变量记录 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"path"}]},{"type":"text","value":" ,"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"pathMap"}]},{"type":"text","value":","},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"nameMap"}]},{"type":"text","value":" ，接着我们来看 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"addRouteRecord"}]},{"type":"text","value":" 这个核心方法"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"这一块代码太多了，列举几个重要的步骤"}]},{"type":"element","tag":"code","props":{"code":"const pathToRegexpOptions: PathToRegexpOptions =\n    route.pathToRegexpOptions || {}\n    \nconst normalizedPath = normalizePath(path, parent, pathToRegexpOptions.strict)\n\nconst record: RouteRecord = {\n  path: normalizedPath,\n  regex: compileRouteRegex(normalizedPath, pathToRegexpOptions),\n  // route对应的组件\n  components: route.components || { default: route.component },\n  // 组件实例\n  instances: {},\n  name,\n  parent,\n  matchAs,\n  redirect: route.redirect,\n  beforeEnter: route.beforeEnter,\n  meta: route.meta || {},\n  props: route.props == null\n    ? {}\n    : route.components\n      ? route.props\n      : { default: route.props }\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"const pathToRegexpOptions: PathToRegexpOptions =\n    route.pathToRegexpOptions || {}\n    \nconst normalizedPath = normalizePath(path, parent, pathToRegexpOptions.strict)\n\nconst record: RouteRecord = {\n  path: normalizedPath,\n  regex: compileRouteRegex(normalizedPath, pathToRegexpOptions),\n  // route对应的组件\n  components: route.components || { default: route.component },\n  // 组件实例\n  instances: {},\n  name,\n  parent,\n  matchAs,\n  redirect: route.redirect,\n  beforeEnter: route.beforeEnter,\n  meta: route.meta || {},\n  props: route.props == null\n    ? {}\n    : route.components\n      ? route.props\n      : { default: route.props }\n}\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"使用 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"recod"}]},{"type":"text","value":" 记录路由配置有利于后续路径切换时计算出新路径，这里的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"path"}]},{"type":"text","value":" 其实是通过 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"path"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"parent"}]},{"type":"text","value":" 拼接处的路径。然后 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"regex"}]},{"type":"text","value":" 使用一个库将 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"path"}]},{"type":"text","value":" 解析为正则表达式。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"如果 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"route"}]},{"type":"text","value":" 有子节点就递归调用 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"addRouteRecord"}]}]},{"type":"element","tag":"code","props":{"code":" // 如果有children 递归调用addRouteRecord\n    route.children.forEach(child => {\n      const childMatchAs = matchAs\n        ? cleanPath(`${matchAs}/${child.path}`)\n        : undefined\n      addRouteRecord(pathList, pathMap, nameMap, child, record, childMatchAs)\n    })\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":" // 如果有children 递归调用addRouteRecord\n    route.children.forEach(child => {\n      const childMatchAs = matchAs\n        ? cleanPath(`${matchAs}/${child.path}`)\n        : undefined\n      addRouteRecord(pathList, pathMap, nameMap, child, record, childMatchAs)\n    })\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"最后映射一张表,并将 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"record·path"}]},{"type":"text","value":" 保存进 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"pathList"}]},{"type":"text","value":", "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"nameMap"}]},{"type":"text","value":" 逻辑相似就不列举了"}]},{"type":"element","tag":"code","props":{"code":"  if (!pathMap[record.path]) {\n    pathList.push(record.path)\n    pathMap[record.path] = record\n  }\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"  if (!pathMap[record.path]) {\n    pathList.push(record.path)\n    pathMap[record.path] = record\n  }\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"废了这么大劲将 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"pathList"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"pathMap"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"nameMap"}]},{"type":"text","value":" 抽出来是为啥呢，首先 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"pathList"}]},{"type":"text","value":" 是记录路由配置所有的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"path"}]},{"type":"text","value":"，然后 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"pathMap"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"nameMap"}]},{"type":"text","value":" 方便我们传入 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"path"}]},{"type":"text","value":" 或者 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"name"}]},{"type":"text","value":" 快速定位到一个 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"record"}]},{"type":"text","value":" ,然后辅助后续路径切换计算路由滴。"}]},{"type":"element","tag":"h2","props":{"id":"addroutes"},"children":[{"type":"text","value":"addRoutes"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"这是在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vue2.2.0"}]},{"type":"text","value":" 之后新添加的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"api"}]},{"type":"text","value":" ,或许很多情况路由并不是写死的，需要动态添加路由。有了前面的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"createRouteMap"}]},{"type":"text","value":" 的基础上我们只需要传入 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"routes"}]},{"type":"text","value":" 、"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"pathList"}]},{"type":"text","value":"、 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"pathMap"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"nameMap"}]},{"type":"text","value":" 即可，他就能在原基础上修改"}]},{"type":"element","tag":"code","props":{"code":"function addRoutes (routes) {\n  createRouteMap(routes, pathList, pathMap, nameMap)\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"function addRoutes (routes) {\n  createRouteMap(routes, pathList, pathMap, nameMap)\n}\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"并且看到在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"createMathcer"}]},{"type":"text","value":" 最后返回了这个方法，所以我们就可以使用这个方法"}]},{"type":"element","tag":"code","props":{"code":"return {\n    match,\n    addRoutes\n  }\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"return {\n    match,\n    addRoutes\n  }\n"}]}]}]},{"type":"element","tag":"h2","props":{"id":"match"},"children":[{"type":"text","value":"match"}]},{"type":"element","tag":"code","props":{"code":"function match (\n  raw: RawLocation,\n  currentRoute?: Route,\n  redirectedFrom?: Location\n): Route {\n  ...\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"function match (\n  raw: RawLocation,\n  currentRoute?: Route,\n  redirectedFrom?: Location\n): Route {\n  ...\n}\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"接下来就是 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"match"}]},{"type":"text","value":" 方法，它接收 3 个参数，其中 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"raw"}]},{"type":"text","value":" 是 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"RawLocation"}]},{"type":"text","value":" 类型，它可以是一个 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"url"}]},{"type":"text","value":" 字符串，也可以是一个 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Location"}]},{"type":"text","value":" 对象；"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"currentRoute"}]},{"type":"text","value":" 是 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Route"}]},{"type":"text","value":" 类型，它表示当前的路径；"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"redirectedFrom"}]},{"type":"text","value":" 和重定向相关。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"match"}]},{"type":"text","value":" 方法返回的是一个路径，它的作用是根据传入的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"raw"}]},{"type":"text","value":" 和当前的路径 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"currentRoute"}]},{"type":"text","value":" 计算出一个新的路径并返回。至于他是如何计算出这条路径的可以详细看一下如何计算出 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"location"}]},{"type":"text","value":" 的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"normalizeLocation"}]},{"type":"text","value":" 方法和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"match"}]},{"type":"text","value":" 方法后面的逻辑。"}]},{"type":"element","tag":"h2","props":{"id":"总结-2"},"children":[{"type":"text","value":"总结"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"createMatcher"}]},{"type":"text","value":": 根据路由的配置描述建立映射表，包括路径、名称到路由 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"record"}]},{"type":"text","value":" 的映射关系, 最重要的就是 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"create-route-map"}]},{"type":"text","value":" 这个方法，这里也是动态路由匹配和嵌套路由的原理。"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"addRoutes"}]},{"type":"text","value":": 动态添加路由配置"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"match"}]},{"type":"text","value":": 根据传入的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"raw"}]},{"type":"text","value":" 和当前的路径 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"currentRoute"}]},{"type":"text","value":" 计算出一个新的路径并返回。"}]}]},{"type":"element","tag":"h2","props":{"id":"路由模式"},"children":[{"type":"text","value":"路由模式"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vue-router"}]},{"type":"text","value":" 支持三种路由模式(mode)："},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"hash"}]},{"type":"text","value":"、"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"history"}]},{"type":"text","value":"、"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"abstract"}]},{"type":"text","value":"，其中 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"abstract"}]},{"type":"text","value":" 是在非浏览器环境下使用的路由模式"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"这一部分在前面初始化 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vueRouter"}]},{"type":"text","value":" 对象时提到过,首先会拿配置项的模式 ，然后根据当前传入的配置判断当前浏览器是否支持这种模式，默认"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"ie9"}]},{"type":"text","value":" 以下会降级为 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"hash"}]},{"type":"text","value":"。 然后根据不同的模式去初始化不同的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"history"}]},{"type":"text","value":" 实例。"}]},{"type":"element","tag":"code","props":{"code":"// 一般分两种模式 hash和history路由 第三种是抽象模式\n    let mode = options.mode || 'hash'\n    // 判断当前传入的配置是否能使用history模式\n    this.fallback = mode === 'history' && !supportsPushState && options.fallback !== false\n    // 降级处理\n    if (this.fallback) {\n      mode = 'hash'\n    }\n    if (!inBrowser) {\n      mode = 'abstract'\n    }\n    this.mode = mode\n\n    // 根据模式实例化不同的history history对象会对路由进行管理 继承于history class\n    switch (mode) {\n      case 'history':\n        this.history = new HTML5History(this, options.base)\n        break\n      case 'hash':\n        this.history = new HashHistory(this, options.base, this.fallback)\n        break\n      case 'abstract':\n        this.history = new AbstractHistory(this, options.base)\n        break\n      default:\n        if (process.env.NODE_ENV !== 'production') {\n          assert(false, `invalid mode: ${mode}`)\n        }\n    }\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"// 一般分两种模式 hash和history路由 第三种是抽象模式\n    let mode = options.mode || 'hash'\n    // 判断当前传入的配置是否能使用history模式\n    this.fallback = mode === 'history' && !supportsPushState && options.fallback !== false\n    // 降级处理\n    if (this.fallback) {\n      mode = 'hash'\n    }\n    if (!inBrowser) {\n      mode = 'abstract'\n    }\n    this.mode = mode\n\n    // 根据模式实例化不同的history history对象会对路由进行管理 继承于history class\n    switch (mode) {\n      case 'history':\n        this.history = new HTML5History(this, options.base)\n        break\n      case 'hash':\n        this.history = new HashHistory(this, options.base, this.fallback)\n        break\n      case 'abstract':\n        this.history = new AbstractHistory(this, options.base)\n        break\n      default:\n        if (process.env.NODE_ENV !== 'production') {\n          assert(false, `invalid mode: ${mode}`)\n        }\n    }\n"}]}]}]},{"type":"element","tag":"h2","props":{"id":"总结-3"},"children":[{"type":"text","value":"总结"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vue-router"}]},{"type":"text","value":" 支持三种路由模式，"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"hash"}]},{"type":"text","value":"、"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"history"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"abstract"}]},{"type":"text","value":" 。默认为 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"hash"}]},{"type":"text","value":" ,如果当前浏览器不支持 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"history"}]},{"type":"text","value":" 则会做降级处理，然后完成 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"history"}]},{"type":"text","value":"的初始化。"}]},{"type":"element","tag":"h2","props":{"id":"router-view--router-link"},"children":[{"type":"text","value":"router-view & router-link"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vue-router"}]},{"type":"text","value":" 在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" 时全局注册了两个组件一个是 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"router-view"}]},{"type":"text","value":" 一个是 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"router-link"}]},{"type":"text","value":" ，这俩个组件都是典型的函数式组件。"}]},{"type":"element","tag":"h2","props":{"id":"router-view"},"children":[{"type":"text","value":"router-view"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"首先在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"router"}]},{"type":"text","value":" 组件执行 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"beforeCreate"}]},{"type":"text","value":" 这个钩子时，把 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"this._route"}]},{"type":"text","value":" 转为了响应式的一个对象"}]},{"type":"element","tag":"code","props":{"code":" Vue.util.defineReactive(this, '_route', this._router.history.current)\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":" Vue.util.defineReactive(this, '_route', this._router.history.current)\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"所以说每次路由切换都会触发 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"router-view"}]},{"type":"text","value":" 重新 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"render"}]},{"type":"text","value":" 从而渲染出新的视图。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"核心的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"render"}]},{"type":"text","value":" 函数作用请看代码注释"}]},{"type":"element","tag":"code","props":{"code":"  render (_, { props, children, parent, data }) {\n    // 标志\n    data.routerView = true\n    // 获取跟 dom\n    const h = parent.$createElement\n    const name = props.name\n    // 注册时定义的原型 $route 可以理解成当前路径\n    const route = parent.$route\n    // 缓存相关\n    const cache = parent._routerViewCache || (parent._routerViewCache = {})\n    \n    // 通过 depth 由router-view组件向上遍历直到跟组件，遇到其他的router-view组件则路由深度+1\n    let depth = 0\n    let inactive = false\n    while (parent && parent._routerRoot !== parent) {\n      // parent.$vnode.data.routerView 为 true 则代表向上寻找的组件也存在嵌套的 router-view \n      if (parent.$vnode && parent.$vnode.data.routerView) {\n        depth++\n      }\n      if (parent._inactive) {\n        inactive = true\n      }\n      parent = parent.$parent\n    }\n    data.routerViewDepth = depth\n\n    if (inactive) {\n      return h(cache[name], data, children)\n    }\n\n   // 通过 matched 记录寻找出对应的 RouteRecord \n    const matched = route.matched[depth]\n    if (!matched) {\n      cache[name] = null\n      return h()\n    }\n // 通过 RouteRecord 找到 component\n    const component = cache[name] = matched.components[name]\n   \n   // 往父组件注册registerRouteInstance方法\n    data.registerRouteInstance = (vm, val) => {     \n      const current = matched.instances[name]\n      if (\n        (val && current !== vm) ||\n        (!val && current === vm)\n      ) {\n        matched.instances[name] = val\n      }\n    }\n  // 渲染组件\n    return h(component, data, children)\n  }\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"  render (_, { props, children, parent, data }) {\n    // 标志\n    data.routerView = true\n    // 获取跟 dom\n    const h = parent.$createElement\n    const name = props.name\n    // 注册时定义的原型 $route 可以理解成当前路径\n    const route = parent.$route\n    // 缓存相关\n    const cache = parent._routerViewCache || (parent._routerViewCache = {})\n    \n    // 通过 depth 由router-view组件向上遍历直到跟组件，遇到其他的router-view组件则路由深度+1\n    let depth = 0\n    let inactive = false\n    while (parent && parent._routerRoot !== parent) {\n      // parent.$vnode.data.routerView 为 true 则代表向上寻找的组件也存在嵌套的 router-view \n      if (parent.$vnode && parent.$vnode.data.routerView) {\n        depth++\n      }\n      if (parent._inactive) {\n        inactive = true\n      }\n      parent = parent.$parent\n    }\n    data.routerViewDepth = depth\n\n    if (inactive) {\n      return h(cache[name], data, children)\n    }\n\n   // 通过 matched 记录寻找出对应的 RouteRecord \n    const matched = route.matched[depth]\n    if (!matched) {\n      cache[name] = null\n      return h()\n    }\n // 通过 RouteRecord 找到 component\n    const component = cache[name] = matched.components[name]\n   \n   // 往父组件注册registerRouteInstance方法\n    data.registerRouteInstance = (vm, val) => {     \n      const current = matched.instances[name]\n      if (\n        (val && current !== vm) ||\n        (!val && current === vm)\n      ) {\n        matched.instances[name] = val\n      }\n    }\n  // 渲染组件\n    return h(component, data, children)\n  }\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"触发更新也就是 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"setter"}]},{"type":"text","value":" 的调用，位于 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"src/index.js"}]}]},{"type":"element","tag":"code","props":{"code":"history.listen(route => {\n  this.apps.forEach((app) => {\n    // 触发 setter\n    app._route = route\n  })\n})\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"history.listen(route => {\n  this.apps.forEach((app) => {\n    // 触发 setter\n    app._route = route\n  })\n})\n"}]}]}]},{"type":"element","tag":"h2","props":{"id":"router-link"},"children":[{"type":"text","value":"router-link"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"分析几个重要的部分"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"设置 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"active"}]},{"type":"text","value":" 路由样式"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"router-link"}]},{"type":"text","value":" 之所以可以添加 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"router-link-active"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"router-link-exact-active"}]},{"type":"text","value":" 这两个 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"class"}]},{"type":"text","value":" 去修改样式，是因为在执行 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"render"}]},{"type":"text","value":" 函数时，会根据当前的路由状态，给渲染出来的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"active"}]},{"type":"text","value":" 元素添加 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"class"}]}]},{"type":"element","tag":"code","props":{"code":"render (h: Function) {\n  ...\n  const globalActiveClass = router.options.linkActiveClass\n  const globalExactActiveClass = router.options.linkExactActiveClass\n  // Support global empty active class\n  const activeClassFallback = globalActiveClass == null\n    ? 'router-link-active'\n    : globalActiveClass\n  const exactActiveClassFallback = globalExactActiveClass == null\n    ? 'router-link-exact-active'\n    : globalExactActiveClass\n    ...\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"render (h: Function) {\n  ...\n  const globalActiveClass = router.options.linkActiveClass\n  const globalExactActiveClass = router.options.linkExactActiveClass\n  // Support global empty active class\n  const activeClassFallback = globalActiveClass == null\n    ? 'router-link-active'\n    : globalActiveClass\n  const exactActiveClassFallback = globalExactActiveClass == null\n    ? 'router-link-exact-active'\n    : globalExactActiveClass\n    ...\n}\n"}]}]}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"router-link"}]},{"type":"text","value":" 默认渲染为 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"a"}]},{"type":"text","value":" 标签，如果不是会去向上查找出第一个 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"a"}]},{"type":"text","value":" 标签"}]}]},{"type":"element","tag":"code","props":{"code":" if (this.tag === 'a') {\n      data.on = on\n      data.attrs = { href }\n    } else {\n      // find the first <a> child and apply listener and href\n      const a = findAnchor(this.$slots.default)\n      if (a) {\n        // in case the <a> is a static node\n        a.isStatic = false\n        const aData = (a.data = extend({}, a.data))\n        aData.on = on\n        const aAttrs = (a.data.attrs = extend({}, a.data.attrs))\n        aAttrs.href = href\n      } else {\n        // 不存在则渲染本身元素\n        data.on = on\n      }\n    }\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":" if (this.tag === 'a') {\n      data.on = on\n      data.attrs = { href }\n    } else {\n      // find the first <a> child and apply listener and href\n      const a = findAnchor(this.$slots.default)\n      if (a) {\n        // in case the <a> is a static node\n        a.isStatic = false\n        const aData = (a.data = extend({}, a.data))\n        aData.on = on\n        const aAttrs = (a.data.attrs = extend({}, a.data.attrs))\n        aAttrs.href = href\n      } else {\n        // 不存在则渲染本身元素\n        data.on = on\n      }\n    }\n"}]}]}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"切换路由，触发相应事件"}]}]},{"type":"element","tag":"code","props":{"code":"const handler = e => {\n  if (guardEvent(e)) {\n    if (this.replace) {\n      // replace路由\n      router.replace(location)\n    } else {\n      // push 路由\n      router.push(location)\n    }\n  }\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"const handler = e => {\n  if (guardEvent(e)) {\n    if (this.replace) {\n      // replace路由\n      router.replace(location)\n    } else {\n      // push 路由\n      router.push(location)\n    }\n  }\n}\n"}]}]}]},{"type":"element","tag":"h2","props":{"id":"权限控制动态路由原理分析"},"children":[{"type":"text","value":"权限控制动态路由原理分析"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"我相信，开发过后台项目的同学经常会碰到以下的场景: 一个系统分为不同的角色，然后不同的角色对应不同的操作菜单和操作权限。例如: 教师可以查询教师自己的个人信息查询然后还可以查询操作学生的信息和学生的成绩系统、学生用户只允许查询个人成绩和信息，不允许更改。在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vue2.2.0"}]},{"type":"text","value":" 之前还没有加入 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"addRoutes"}]},{"type":"text","value":" 这个 API 是十分困难的的。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"目前主流的路由权限控制的方式是:"}]},{"type":"element","tag":"ol","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"前端在登录之后获取到 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"JWT 令牌"}]},{"type":"text","value":" 前端在全局路由拦截,并在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"route.js"}]},{"type":"text","value":" 定义一套前端的路由表"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"后端根据登录信息返回给前端对应的身份信息，并且涉及到身份信息操作的接口都需要做身份校验处理。 当然这里也可以在数据库中提前定义好一张 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"roles-router"}]},{"type":"text","value":" 表,然后在查询用户信息时将对应的路由树状表返给前端"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"前端根据当前的角色将对应的权限的路由表拼接到常规路由表后面"}]}]},{"type":"element","tag":"h3","props":{"id":"登录生成动态路由全过程"},"children":[{"type":"text","value":"登录生成动态路由全过程"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"了解如何控制动态路由之后，下面是我画的一张全过程流程图\n"},{"type":"element","tag":"img","props":{"alt":"","src":"//p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/cf68a840ca31484c985517c869e2873c~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"前端在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"beforeEach"}]},{"type":"text","value":" 中判断:"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"缓存中存在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"JWT令牌"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"访问 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"/login"}]},{"type":"text","value":" : 重定向到首页"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"('/')"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"访问 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"/login"}]},{"type":"text","value":" 以外的路由:  首次访问，获取用户角色信息，然后生成动态路由，然后访问以 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"replace"}]},{"type":"text","value":" 模式访问 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"/xxx"}]},{"type":"text","value":" 路由。这种模式用户在登录之后不会在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"history"}]},{"type":"text","value":" 存放记录，回退直接显示空白页面"}]}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"不存在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"JWT令牌"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"路由在白名单中: 正常访问 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"/xxx"}]},{"type":"text","value":" 路由"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"不在白名单中: 重定向到 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"/login"}]},{"type":"text","value":" 页面"}]}]}]}]},{"type":"element","tag":"h3","props":{"id":"结合框架源码分析"},"children":[{"type":"text","value":"结合框架源码分析"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"下面结合 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vue-element-admin"}]},{"type":"text","value":" 的源码分析该框架中如何处理路由逻辑的。"}]},{"type":"element","tag":"h3","props":{"id":"路由访问逻辑分析"},"children":[{"type":"text","value":"路由访问逻辑分析"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"首先可以定位到和入口文件 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"main.js"}]},{"type":"text","value":" 同级的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"permission.js"}]},{"type":"text","value":" , 全局路由守卫处理就在此"}]},{"type":"element","tag":"code","props":{"code":"const whiteList = ['/login', '/register'] // 路由白名单，不会重定向\n\n// 全局路由守卫\nrouter.beforeEach(async(to, from, next) => {\n  NProgress.start() //路由加载进度条\n  // 设置meta标题\n  document.title = getPageTitle(to.meta.title)\n  // 判断token是否存在\n  const hasToken = getToken()\n  if (hasToken) {\n    if (to.path === '/login') {\n      // 有token 跳转首页\n      next({ path: '/' })\n      NProgress.done()\n    } else {\n      const hasRoles = store.getters.roles && store.getters.roles.length > 0\n      if (hasRoles) {\n        next()\n      } else {\n        try {\n          // 获取动态路由，添加到路由表中\n          const { roles } = await store.dispatch('user/getInfo')\n          const accessRoutes = await store.dispatch('permission/generateRoutes', roles)\n          router.addRoutes(accessRoutes)\n          //  使用 replace 访问路由，不会在 history 中留下记录，登录到dashbord时回退空白页面\n          next({ ...to, replace: true })\n        } catch (error) {\n          next('/login')\n          NProgress.done()\n        }\n      }\n    }\n  } else {\n    // 无token\n    // 白名单不用重定向 直接访问\n    if (whiteList.indexOf(to.path) !== -1) {\n      next()\n    } else {\n      // 携带参数为重定向到前往的路径\n      next(`/login?redirect=${to.path}`)\n      NProgress.done()\n    }\n  }\n})\n\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"const whiteList = ['/login', '/register'] // 路由白名单，不会重定向\n\n// 全局路由守卫\nrouter.beforeEach(async(to, from, next) => {\n  NProgress.start() //路由加载进度条\n  // 设置meta标题\n  document.title = getPageTitle(to.meta.title)\n  // 判断token是否存在\n  const hasToken = getToken()\n  if (hasToken) {\n    if (to.path === '/login') {\n      // 有token 跳转首页\n      next({ path: '/' })\n      NProgress.done()\n    } else {\n      const hasRoles = store.getters.roles && store.getters.roles.length > 0\n      if (hasRoles) {\n        next()\n      } else {\n        try {\n          // 获取动态路由，添加到路由表中\n          const { roles } = await store.dispatch('user/getInfo')\n          const accessRoutes = await store.dispatch('permission/generateRoutes', roles)\n          router.addRoutes(accessRoutes)\n          //  使用 replace 访问路由，不会在 history 中留下记录，登录到dashbord时回退空白页面\n          next({ ...to, replace: true })\n        } catch (error) {\n          next('/login')\n          NProgress.done()\n        }\n      }\n    }\n  } else {\n    // 无token\n    // 白名单不用重定向 直接访问\n    if (whiteList.indexOf(to.path) !== -1) {\n      next()\n    } else {\n      // 携带参数为重定向到前往的路径\n      next(`/login?redirect=${to.path}`)\n      NProgress.done()\n    }\n  }\n})\n\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"这里的代码我都添加了注释方便大家好去理解，总结为一句话就是访问路由 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"/xxx"}]},{"type":"text","value":" ，首先需要校验 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"token"}]},{"type":"text","value":"是否存在，如果有就判断是否访问的是登录路由，不是则需要判断该用户是否是第一访问首页，然后生成动态路由，如果没有 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"token"}]},{"type":"text","value":" 就去检查路由是否在白名单(任何情况都能访问的路由)，在的话就访问，否则重定向回登录页面。"}]},{"type":"element","tag":"h3","props":{"id":"结合vuex生成动态路由"},"children":[{"type":"text","value":"结合Vuex生成动态路由"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"下面就是分析这一步 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"const accessRoutes = await store.dispatch('permission/generateRoutes', roles)"}]},{"type":"text","value":" 是怎么把路由生成出来的。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"首选 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vue-element-admin"}]},{"type":"text","value":" 中路由是分为两种的:"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"constantRoutes: 不需要权限判断的路由"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"asyncRoutes: 需要动态判断权限的路由"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","src":"//p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/152acc3571074c03af839fbf00b5ac45~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"生成动态路由的源码位于 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"src/store/modules/permission.js"}]},{"type":"text","value":" 中的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"generateRoutes"}]},{"type":"text","value":" 方法，源码如下："}]},{"type":"element","tag":"code","props":{"code":" generateRoutes({ commit }, roles) {\n    return new Promise(resolve => {\n      //   debugger\n      let accessedRoutes\n      if (roles.includes('admin')) {\n        accessedRoutes = asyncRoutes || []\n      } else {\n      // 不是admin 去遍历生成对应的权限路由表\n        accessedRoutes = filterAsyncRoutes(asyncRoutes, roles)\n      }\n      commit('SET_ROUTES', accessedRoutes)\n      resolve(accessedRoutes)\n    })\n  }\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":" generateRoutes({ commit }, roles) {\n    return new Promise(resolve => {\n      //   debugger\n      let accessedRoutes\n      if (roles.includes('admin')) {\n        accessedRoutes = asyncRoutes || []\n      } else {\n      // 不是admin 去遍历生成对应的权限路由表\n        accessedRoutes = filterAsyncRoutes(asyncRoutes, roles)\n      }\n      commit('SET_ROUTES', accessedRoutes)\n      resolve(accessedRoutes)\n    })\n  }\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"从 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"route.js"}]},{"type":"text","value":" 读取 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"asyncRoutes"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"constantRoutes"}]},{"type":"text","value":" 之后首先判断当前角色是否是 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"admin"}]},{"type":"text","value":" ，是的话默认超级管理员能够访问所有的路由，当然这里也可以自定义，否则去过滤出路由权限路由表，然后保存到"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vuex"}]},{"type":"text","value":"中。 最后将过滤之后的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"asyncRoutes"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"constantRoutes"}]},{"type":"text","value":" 进行合并。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"过滤权限路由的源码如下:"}]},{"type":"element","tag":"code","props":{"code":"export function filterAsyncRoutes(routes, roles) {\n  const res = []\n  routes.forEach(route => {\n    // 浅拷贝\n    const tmp = { ...route }\n    if (hasPermission(roles, tmp)) {\n      if (tmp.children) {\n        tmp.children = filterAsyncRoutes(tmp.children, roles)\n      }\n      res.push(tmp)\n    }\n  })\n  return res\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"export function filterAsyncRoutes(routes, roles) {\n  const res = []\n  routes.forEach(route => {\n    // 浅拷贝\n    const tmp = { ...route }\n    if (hasPermission(roles, tmp)) {\n      if (tmp.children) {\n        tmp.children = filterAsyncRoutes(tmp.children, roles)\n      }\n      res.push(tmp)\n    }\n  })\n  return res\n}\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"首先定义一个空数组，对传入 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"asyncRoutes"}]},{"type":"text","value":" 进行遍历，判断每个路由是否具有权限，未命中的权限路由直接舍弃\n判断权限方法如下:"}]},{"type":"element","tag":"code","props":{"code":"function hasPermission(roles, route) {\n  if (route.meta && route.meta.roles) {\n    // roles有对应路由元定义的role 就返回true\n    return roles.some(role => route.meta.roles.includes(role))\n  } else {\n    return true\n  }\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"function hasPermission(roles, route) {\n  if (route.meta && route.meta.roles) {\n    // roles有对应路由元定义的role 就返回true\n    return roles.some(role => route.meta.roles.includes(role))\n  } else {\n    return true\n  }\n}\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"接着需要判断二级路由、三级路由等等的情况，再做一层迭代处理，最后将过滤出来的路由推进数组返回。然后追加到 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"constantRoutes"}]},{"type":"text","value":"后面"}]},{"type":"element","tag":"code","props":{"code":" SET_ROUTES: (state, routes) => {\n    state.addRoutes = routes\n    state.routes = constantRoutes.concat(routes)\n  }\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":" SET_ROUTES: (state, routes) => {\n    state.addRoutes = routes\n    state.routes = constantRoutes.concat(routes)\n  }\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"动态路由生成全过程"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","src":"//p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/532453ffff994b01a5f3d9c70737be1f~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]}]},{"type":"element","tag":"h2","props":{"id":"总结-4"},"children":[{"type":"text","value":"总结"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vue-router"}]},{"type":"text","value":"源码"},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"注册: 执行 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" 方法，注入生命周期钩子初始化"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"vueRouter: 当组件执行 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"beforeCreate"}]},{"type":"text","value":" 传入 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"router"}]},{"type":"text","value":" 实例时,执行 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"init"}]},{"type":"text","value":" 函数，然后执行 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"history.transitionTo"}]},{"type":"text","value":" 路由过渡"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"matcher : 根据传入的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"routes"}]},{"type":"text","value":" 配置创建对应的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"pathMap"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"nameMap"}]},{"type":"text","value":",可以根据传入的位置和路径计算出新的位置并匹配对应的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"record"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"router-view: 调用父组件上存储的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"$route.match"}]},{"type":"text","value":" 控制路由对应的组件的渲染情况，并且支持嵌套。"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"router-link: 通过 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"to"}]},{"type":"text","value":" 来决定点击事件跳转的目标路由组件，并且支持渲染成不同的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"tag"}]},{"type":"text","value":",还可以修改激活路由的样式。"}]}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"权限控制动态路由:"},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"路由逻辑: 全局路由拦截，从缓存中获取令牌，存在的话如果首次进入路由需要获取用户信息，生成动态路由，这里需要处理 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"/login"}]},{"type":"text","value":" 特殊情况，不存在则判断白名单然后走对应的逻辑"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"动态生成路由: 传入需要 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"router.js"}]},{"type":"text","value":" 定义的两种路由。判断当前身份是否是管理员，是则直接拼接，否则需要过滤出具备权限的路由，最后拼接到常规路由后面，通过 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"addRoutes"}]},{"type":"text","value":" 追加。"}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"个人感悟"}]},{"type":"text","value":":"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"或许阅读源码的作用不能像一些文档一样直接立马对日常开发有所帮助，但是它的影响是长远的，在读源码的过程中都可以学到类似闭包、设计模式、时间循环、回调等等 JS 进阶技能，并稳固并提升了你的 JS 基础。当然这篇文章缺陷的，有几个地方都没有分析到，比如导航守卫实现原理和路由懒加载实现原理，这一部分，我还在摸索当中。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"如果一味的死记硬背一些所谓的面经，或者直接死记硬背相关的框架行为或者 API ，你很难在遇到比较复杂的问题下面去快速定位问题，解怎么去解决问题，而且我发现很多人在使用一个新框架之后遇到点问题都会立马去提对应的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Issues"}]},{"type":"text","value":" ,但是许多问题都是因为我们并未按照设计者开发初设定的方向才导致错误的，更多都是些粗心大意造成的问题。"}]},{"type":"element","tag":"blockquote","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"参考文章"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://juejin.im/post/6844904064367460366","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"带你全面分析vue-router源码 (万字长文)"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/answershuto/learnVue","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"vuejs 源码解析"}]}]}]}]},"publishedAt":"2020-12-01","status":"published","tags":["vue"],"body":{"type":"root","children":[{"type":"element","tag":"toc","props":{},"children":[]},{"type":"element","tag":"tip","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"首先阅读源码之前最好是将 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vue-router"}]},{"type":"text","value":" 的源码下载下来，然后第一遍阅读建议先跟着"},{"type":"element","tag":"a","props":{"href":"https://router.vuejs.org/zh/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"官方文档"}]},{"type":"text","value":"先走一遍基础用法。然后第二遍开始阅读源码，首先理清楚各层级目录的作用和抽出一些核心的文件出来，过一遍代码的同时写个小的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"demo"}]},{"type":"text","value":" 边看边打断点调试，看不懂没关系，可以边看边参考一些总结的比较好的文章，最后将整个注册到 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"init"}]},{"type":"text","value":"到生成 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"matcher"}]},{"type":"text","value":" 等等过程根据自己的理解整理出来，然后画一画相关的知识脑图加深印象。"}]}]},{"type":"element","tag":"h2","props":{"id":"前置知识-flow-语法"},"children":[{"type":"text","value":"前置知识: flow 语法"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"\bJS"}]},{"type":"text","value":" 在编译过程中可能看不出一些隐蔽的错误，但在运行过程中会报各种各样的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"bug"}]},{"type":"text","value":"。"},{"type":"element","tag":"a","props":{"href":"https://flow.org/en/docs/getting-started/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Flow"}]},{"type":"text","value":" 的作用就是编译期间进行静态类型检查，尽早发现错误，抛出异常。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue"}]},{"type":"text","value":" 、"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue-router"}]},{"type":"text","value":" 等大型项目往往需要这种工具去做静态类型检查以保证代码的可维护性和可靠性。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"使用 Flow"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"首先在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"index.js"}]},{"type":"text","value":" 文件中输入以下代码"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"// @flow\nfunction foo(x: ?number): string {\n  if (x) {\n    return x;\n  }\n  return \"default string\";\n}\n\nfoo(\"hello\")\n\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// @flow"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"foo"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"x"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"?"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"number"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"):"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"string"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"x"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"x"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"default string"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"foo"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"hello"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"然后安装 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"flow"}]},{"type":"text","value":",并初始化 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".flowconfig"}]}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"bash","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"npm install flow-bin -g\n\ncd test\n\nflow init\n\nflow\n","language":"bash"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"npm install flow-bin -g"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"cd"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"test"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"flow init"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"flow"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"这个时候不出意外就会抛出异常提示，这就是简单的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"flow"}]},{"type":"text","value":" 使用方法。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"定义不同类型的类型声明"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"字符串:"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"// @flow\nfunction concat(a: string, b: string) {\n  return a + b;\n}\n\nconcat(\"A\", \"B\"); // Works!\nconcat(1, 2); // Error!\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// @flow"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"concat"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"a"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"string"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" b"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"string"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"a"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"+"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"b"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"concat"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"A"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"B"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// Works!"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"concat"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"1"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"2"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// Error!"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"boolean:"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"// @flow\nfunction acceptsBoolean(value: boolean) {\n  // ...\n}\n\nacceptsBoolean(true);  // Works!\nacceptsBoolean(false); // Works!\nacceptsBoolean(\"foo\"); // Error!\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// @flow"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"acceptsBoolean"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"value"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"boolean"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// ..."}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"acceptsBoolean"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"true"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// Works!"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"acceptsBoolean"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"false"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// Works!"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"acceptsBoolean"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"foo"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// Error!"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"number + 设置默认值 :"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"// @flow\nfunction concat(a: number = 1, b: number) {\n  return a + b;\n}\n\nconcat(\"A\", \"B\"); // Error!\nconcat(1, 2); // Works!\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// @flow"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"concat"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"a"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"number"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"1"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" b"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"number"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"a"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"+"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"b"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"concat"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"A"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"B"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// Error!"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"concat"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"1"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"2"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// Works!"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"null 或者 undefined(void处理):"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"// @flow\nfunction acceptsNull(value: null) {\n  /* ... */\n}\n\nfunction acceptsUndefined(value: void) {\n  /* ... */\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// @flow"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"acceptsNull"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"value"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"null"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"/* ... */"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"acceptsUndefined"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"value"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"void"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"/* ... */"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"动态类型:"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"// @flow\nfunction acceptsMaybeString(value: ?string) {\n  // value可能为值类型的某一个\n}\n\n// @flow\nfunction acceptNumberOrString(value: string | number){\n\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// @flow"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"acceptsMaybeString"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"value"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"?"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"string"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// value可能为值类型的某一个"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// @flow"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"acceptNumberOrString"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"value"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"string"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"|"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"number"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"){"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"数组:"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":" // @flow\n function acceptArray(value: Array<number>) {\n\n }\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// @flow"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"acceptArray"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"value"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Array"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"number"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">)"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"对象:"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":" // @flow\n function acceptObject(value: obj){\n\n }\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// @flow"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"acceptObject"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"value"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"obj"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"){"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"另外还支持自定义类型等等，具体用法还需要参考 "},{"type":"element","tag":"a","props":{"href":"https://flow.org/en/docs/types/primitives/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"flow官网"}]}]},{"type":"element","tag":"h2","props":{"id":"注册"},"children":[{"type":"text","value":"注册"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"我们平时在使用 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue-Router"}]},{"type":"text","value":" 的时候通常需要在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"main.js"}]},{"type":"text","value":" 中初始化 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue"}]},{"type":"text","value":" 实例时将 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vue-router"}]},{"type":"text","value":" 实例对象当做参数传入"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"import Router from 'vue-router'\nVue.use(Router)\n\nconst routes = [\n  {\n    path: \"/\",\n    component: goods\n  },\n  {\n    path: \"/comment\",\n    name: \"comment\",\n    component: comment\n  },\n  {\n    path: \"/seller\",\n    name: \"seller\",\n    component: seller\n  }\n];\n\nconst router = new Router({\n  mode: \"history\",\n  linkActiveClass: \"active\",\n  //   指定点击后的样式名\n  base: process.env.BASE_URL,\n  routes\n});\n\nnew Vue({\n    router,\n    store,\n    render: h => h(App)\n}).$mount(\"#app\");\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" Router "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"vue-router"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"Vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"use"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"(Router)"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" routes "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ["}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"component"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" goods"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/comment"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"name"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"comment"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"component"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" comment"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/seller"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"name"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"seller"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"component"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" seller"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" router "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"new"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"Router"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"mode"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"history"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"linkActiveClass"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"active"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//   指定点击后的样式名"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"base"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" process"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"env"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"BASE_URL"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  routes"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"new"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"Vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    router"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    store"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"render"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" h "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"h"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"(App)"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"$mount"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"#app"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]}]}]}]}]},{"type":"element","tag":"h2","props":{"id":"vueuse"},"children":[{"type":"text","value":"Vue.use"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"那么 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue.use(Router)"}]},{"type":"text","value":" 又在做什么事情呢"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"问题定位到 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue"}]},{"type":"text","value":" 源码中的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"src/core/global-api/use.js"}]}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"export function initUse (Vue: GlobalAPI) {\n  Vue.use = function (plugin: Function | Object) {\n    // 拿到installPlugins \n    const installedPlugins = (this._installedPlugins || (this._installedPlugins = []))\n    // 保证不会重复注册\n    if (installedPlugins.indexOf(plugin) > -1) {\n      return this\n    }\n\n    // 获取第一个参数plugins意外的参数\n    const args = toArray(arguments, 1)\n    // 将Vue实例添加到参数\n    args.unshift(this)\n    // 执行plugin的install方法 每个insatll方法的第一个参数都会变成Vue，不需要额外引入\n    if (typeof plugin.install === 'function') {\n      plugin.install.apply(plugin, args)\n    } else if (typeof plugin === 'function') {\n      plugin.apply(null, args)\n    }\n    // 最后将installPlugins保存 \n    installedPlugins.push(plugin)\n    return this\n  }\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"initUse"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"Vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"GlobalAPI"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"Vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"use"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"plugin"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"|"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Object"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 拿到installPlugins "}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"installedPlugins"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"_installedPlugins"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"||"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"_installedPlugins"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" []))"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 保证不会重复注册"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"installedPlugins"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"indexOf"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"plugin"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"-"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"1"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 获取第一个参数plugins意外的参数"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"args"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"toArray"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"arguments"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"1"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 将Vue实例添加到参数"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"args"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"unshift"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 执行plugin的install方法 每个insatll方法的第一个参数都会变成Vue，不需要额外引入"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"typeof"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"plugin"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"install"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"==="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"plugin"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"install"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"apply"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"plugin"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"args"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"else"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"typeof"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"plugin"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"==="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"plugin"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"apply"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"null,"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"args"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 最后将installPlugins保存 "}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"installedPlugins"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"push"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"plugin"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"可以看到 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue"}]},{"type":"text","value":" 的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"use"}]},{"type":"text","value":" 方法会接受一个 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"plugin"}]},{"type":"text","value":" 参数，然后使用 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"installPlugins"}]},{"type":"text","value":"数组 保存已经注册过的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"plugin"}]},{"type":"text","value":" 。 首先保证 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"plugin"}]},{"type":"text","value":" 不被重复注册，然后将 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue"}]},{"type":"text","value":" 从函数参数中取出，将整个 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue"}]},{"type":"text","value":" 作为 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"plugin"}]},{"type":"text","value":"的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" 方法的第一个参数，这样做的好处就是不需要麻烦的另外引入 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue"}]},{"type":"text","value":" ,便于操作, 接着就去判断 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"plugin"}]},{"type":"text","value":" 上是否存在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" 方法。存在则将赋值后的参数传入执行 ，最后将所有的存在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" 方法的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"plugin"}]},{"type":"text","value":" 交给 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"installPlugins"}]},{"type":"text","value":" 维护。"}]},{"type":"element","tag":"h2","props":{"id":"install"},"children":[{"type":"text","value":"install"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"了解清楚 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue.use"}]},{"type":"text","value":" 的结构之后，可以得出 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue"}]},{"type":"text","value":" 注册插件其实就是在执行插件的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" 方法，参数的第一项就是"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue"}]},{"type":"text","value":",所以我们将代码定位到 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vue-router"}]},{"type":"text","value":" 源码中的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"src/install.js"}]}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"// 保存Vue的局部变量\nexport let _Vue\n\nexport function install (Vue) {\n  // 如果已安装\n  if (install.installed && _Vue === Vue) return\n  install.installed = true\n // 局部变量保留传入的Vue\n  _Vue = Vue\n\n  const isDef = v => v !== undefined\n\n  const registerInstance = (vm, callVal) => {\n    let i = vm.$options._parentVnode\n    if (isDef(i) && isDef(i = i.data) && isDef(i = i.registerRouteInstance)) {\n      i(vm, callVal)\n    }\n  }\n\n  // 全局混入钩子函数 每个组件都会有这些钩子函数，执行就会走这里的逻辑\n  Vue.mixin({\n    beforeCreate () {\n      if (isDef(this.$options.router)) {\n        // new Vue时传入的根组件router router对象传入时就可以拿到this.$options.router\n        // 跟router\n        this._routerRoot = this\n        this._router = this.$options.router\n        this._router.init(this)\n        // 变成响应式\n        Vue.util.defineReactive(this, '_route', this._router.history.current)\n      } else {\n        // 非根组件访问根组件通过$parent\n        this._routerRoot = (this.$parent && this.$parent._routerRoot) || this\n      }\n      registerInstance(this, this)\n    },\n    destroyed () {\n      registerInstance(this)\n    }\n  })\n\n  // 通过get方法 原型加入$router 和 $route\n  Object.defineProperty(Vue.prototype, '$router', {\n    get () { return this._routerRoot._router }\n  })\n\n  Object.defineProperty(Vue.prototype, '$route', {\n    get () { return this._routerRoot._route }\n  })\n// 全局注册\n  Vue.component('RouterView', View)\n  Vue.component('RouterLink', Link)\n// 获取合并策略\n  const strats = Vue.config.optionMergeStrategies\n  // use the same hook merging strategy for route hooks\n  strats.beforeRouteEnter = strats.beforeRouteLeave = strats.beforeRouteUpdate = strats.created\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 保存Vue的局部变量"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"let"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" _Vue"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"install"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"Vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 如果已安装"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"install"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"installed"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"&&"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"_Vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"==="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"Vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"install"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"installed"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"true"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 局部变量保留传入的Vue"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"_Vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"Vue"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"isDef"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"v"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"v"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"!=="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"undefined"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"registerInstance"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"vm"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"callVal"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"let"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"i"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"vm"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$options"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"_parentVnode"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"isDef"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"i"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"&&"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"isDef"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"i"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"i"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"data"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"&&"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"isDef"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"i"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"i"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"registerRouteInstance"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")) "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"i"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"vm"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"callVal"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 全局混入钩子函数 每个组件都会有这些钩子函数，执行就会走这里的逻辑"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"Vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"mixin"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    beforeCreate "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"isDef"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$options"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"router"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")) "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// new Vue时传入的根组件router router对象传入时就可以拿到this.$options.router"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 跟router"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"_routerRoot"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"_router"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$options"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"router"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"_router"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"init"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 变成响应式"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"Vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"util"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"defineReactive"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this,"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"_route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"_router"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"history"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"current"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"else"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 非根组件访问根组件通过$parent"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"_routerRoot"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$parent"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"&&"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$parent"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"_routerRoot"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"||"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"registerInstance"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this,"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    destroyed "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"registerInstance"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 通过get方法 原型加入$router 和 $route"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Object"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"defineProperty"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"prototype"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"$router"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    get "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"_routerRoot"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"_router"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Object"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"defineProperty"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"prototype"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"$route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    get "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"_routerRoot"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"_route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 全局注册"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"Vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"component"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"RouterView"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"View"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"Vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"component"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"RouterLink"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"Link"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 获取合并策略"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"strats"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"Vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"config"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"optionMergeStrategies"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// use the same hook merging strategy for route hooks"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"strats"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"beforeRouteEnter"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"strats"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"beforeRouteLeave"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"strats"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"beforeRouteUpdate"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"strats"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"created"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"可以看到这段代码核心部分就是在执行 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" 方法时使用 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"mixin"}]},{"type":"text","value":" 的方式将每个组件都混入 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"beforeCreate"}]},{"type":"text","value":", "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"destroyed"}]},{"type":"text","value":" 这两个生命周期钩子。在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"beforeCreate"}]},{"type":"text","value":" 函数中会去判断当前传入的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"router"}]},{"type":"text","value":" 实例是否是跟组件，如果是，则将 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"_routerRoot"}]},{"type":"text","value":" 赋值为当前组件实例、"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"_router"}]},{"type":"text","value":" 赋值为传入的"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"VueRouter"}]},{"type":"text","value":" 实例对象，接着执行 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"init"}]},{"type":"text","value":" 方法初始化 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"router"}]},{"type":"text","value":",然后将 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"this_route"}]},{"type":"text","value":" 响应式化。非根组件的话 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"_routerRoot"}]},{"type":"text","value":"  就指向 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"$parent"}]},{"type":"text","value":" 父实例。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"然后执行 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"registerInstance(this,this)"}]},{"type":"text","value":" 方法，该方法后文会分析。原型加入 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"$router"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"$route"}]},{"type":"text","value":" ，最后注册 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"ROuterView"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"RouterLink"}]},{"type":"text","value":"，这就是整个 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"install"}]},{"type":"text","value":"的过程。"}]},{"type":"element","tag":"h2","props":{"id":"总结"},"children":[{"type":"text","value":"总结"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue.use(plugin)"}]},{"type":"text","value":" 实际上在执行 plugin上的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" 方法，"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"insatll"}]},{"type":"text","value":" 方法有个重要的步骤就是使用 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"mixin"}]},{"type":"text","value":" 在组件中混入 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"beforeCreate"}]},{"type":"text","value":" , "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"destory"}]},{"type":"text","value":" 这俩个生命周期钩子，然后在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"beforeCreate"}]},{"type":"text","value":" 这个钩子进行初始化。"}]},{"type":"element","tag":"h2","props":{"id":"vuerouter"},"children":[{"type":"text","value":"vueRouter"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"接着就是这个最重要的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"class"}]},{"type":"text","value":": "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vueRouter"}]},{"type":"text","value":" 。这一部分代码比较多，所以不一一列举，挑重点分析，"},{"type":"element","tag":"a","props":{"href":"https://github.com/vuejs/vue-router/blob/v3.1.2/src/index.js","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"vueRouter源码地址"}]}]},{"type":"element","tag":"h2","props":{"id":"构造函数"},"children":[{"type":"text","value":"构造函数"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"  constructor (options: RouterOptions = {}) {\n    this.app = null\n    this.apps = []\n    this.options = options\n    this.beforeHooks = []\n    this.resolveHooks = []\n    this.afterHooks = []\n    this.matcher = createMatcher(options.routes || [], this)\n\n    // 一般分两种模式 hash和history路由 第三种是抽象模式\n    let mode = options.mode || 'hash'\n    // 判断当前传入的配置是否能使用history模式\n    this.fallback = mode === 'history' && !supportsPushState && options.fallback !== false\n    // 降级处理\n    if (this.fallback) {\n      mode = 'hash'\n    }\n    if (!inBrowser) {\n      mode = 'abstract'\n    }\n    this.mode = mode\n\n    // 根据模式实例化不同的history history对象会对路由进行管理 继承于history class\n    switch (mode) {\n      case 'history':\n        this.history = new HTML5History(this, options.base)\n        break\n      case 'hash':\n        this.history = new HashHistory(this, options.base, this.fallback)\n        break\n      case 'abstract':\n        this.history = new AbstractHistory(this, options.base)\n        break\n      default:\n        if (process.env.NODE_ENV !== 'production') {\n          assert(false, `invalid mode: ${mode}`)\n        }\n    }\n  }\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"constructor"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" (options: RouterOptions "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"app"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"null"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"apps"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" []"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"options"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"options"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"beforeHooks"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" []"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"resolveHooks"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" []"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"afterHooks"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" []"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"matcher"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"createMatcher"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"options"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"routes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"||"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" []"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 一般分两种模式 hash和history路由 第三种是抽象模式"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"let"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"mode"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"options"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"mode"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"||"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"hash"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 判断当前传入的配置是否能使用history模式"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"fallback"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"mode"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"==="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"history"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"&&"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"!"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"supportsPushState"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"&&"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"options"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"fallback"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"!=="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"false"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 降级处理"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"fallback"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"mode"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"hash"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"!"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"inBrowser"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"mode"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"abstract"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"mode"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"mode"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 根据模式实例化不同的history history对象会对路由进行管理 继承于history class"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"switch"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"mode"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"case"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"history"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"history"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"new"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"HTML5History"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this,"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"options"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"base"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"break"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"case"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"hash"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"history"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"new"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"HashHistory"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this,"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"options"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"base"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"fallback"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"break"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"case"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"abstract"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"history"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"new"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"AbstractHistory"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this,"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"options"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"base"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"break"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"process"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"env"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"NODE_ENV"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"!=="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"production"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"          "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"assert"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"false"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"`"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"invalid mode: "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"${"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"mode"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}`"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"首先在初始化 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vueRouter"}]},{"type":"text","value":" 整个对象时定义了许多变量，"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"app"}]},{"type":"text","value":" 代表 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue"}]},{"type":"text","value":" 实例，"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"options"}]},{"type":"text","value":" 代表传入的配置参数，然后就是路由拦截有用的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"hooks"}]},{"type":"text","value":"和重要的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"matcher"}]},{"type":"text","value":"(后文会写到)。构造函数其实在做两件事情: 1. 确定当前路由使用的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"mode"}]},{"type":"text","value":"，2. 实例化对应的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"history"}]},{"type":"text","value":"对象。"}]},{"type":"element","tag":"h2","props":{"id":"init"},"children":[{"type":"text","value":"init"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"接着完成实例化 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vueRouter"}]},{"type":"text","value":" 之后，如果这个实例传入后，也就是刚开始说的将 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vueRouter"}]},{"type":"text","value":" 实例在初始化 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue"}]},{"type":"text","value":" 时传入，他会在执行 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"beforeCreate"}]},{"type":"text","value":" 时执行 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"init"}]},{"type":"text","value":" 方法`"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"init (app: any) {\n  process.env.NODE_ENV !== 'production' && assert(\n    install.installed,\n    `not installed. Make sure to call \\`Vue.use(VueRouter)\\` ` +\n    `before creating root instance.`\n  )\n  this.apps.push(app)\n  // 确保后面的逻辑只走一次\n  if (this.app) {\n    return\n  }\n\n  this.app = app\n  const history = this.history\n  if (history instanceof HTML5History) {\n    history.transitionTo(history.getCurrentLocation())\n  } else if (history instanceof HashHistory) {\n    const setupHashListener = () => {\n      history.setupListeners()\n    }\n    history.transitionTo(\n      history.getCurrentLocation(),\n      setupHashListener,\n      setupHashListener\n    )\n  }\n  history.listen(route => {\n    this.apps.forEach((app) => {\n      app._route = route\n    })\n  })\n}\n\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"init"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" (app: any) "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"process"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"env"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"NODE_ENV"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"!=="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"production"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"&&"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"assert"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"install"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"installed"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"`"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"not installed. Make sure to call "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\`"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"Vue.use(VueRouter)"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\`"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"`"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"+"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"`"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"before creating root instance."}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"`"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  )"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"apps"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"push"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"app"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 确保后面的逻辑只走一次"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"app"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"app"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"app"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"history"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"history"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"history"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"instanceof"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"HTML5History"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"history"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"transitionTo"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"history"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"getCurrentLocation"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"())"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"else"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"history"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"instanceof"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"HashHistory"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"setupHashListener"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"history"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"setupListeners"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"()"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"history"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"transitionTo"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"history"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"getCurrentLocation"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"setupHashListener"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"setupHashListener"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    )"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"history"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"listen"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"apps"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"forEach"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"app"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"app"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"_route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"route"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"init"}]},{"type":"text","value":" 方法传入 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue"}]},{"type":"text","value":" 实例，保存到 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"this.apps"}]},{"type":"text","value":" 当中。"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue实例"}]},{"type":"text","value":" 会取出当前的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"this.history"}]},{"type":"text","value":"，如果是哈希路由，先走 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"setupHashListener"}]},{"type":"text","value":" 函数，然后调一个关键的函数 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"transitionTo"}]},{"type":"text","value":" ,这个函数其实调用了 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"this.matcher.match"}]},{"type":"text","value":" 去匹配。"}]},{"type":"element","tag":"h2","props":{"id":"总结-1"},"children":[{"type":"text","value":"总结"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"初始化路由需要传入 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vueRouter"}]},{"type":"text","value":" 实例对象，然后在组件初始化阶段执行 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"beforeCreate"}]},{"type":"text","value":" 钩子，调用 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"init"}]},{"type":"text","value":" 方法，接着拿到 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"this.history"}]},{"type":"text","value":" 去调用 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"transitionTo"}]},{"type":"text","value":" 进行路由过渡。"}]},{"type":"element","tag":"h2","props":{"id":"matcher"},"children":[{"type":"text","value":"matcher"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"之前在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vueRouter"}]},{"type":"text","value":" 的构造函数中初始化了 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"macther"}]},{"type":"text","value":" ,本节将详细分析下面这句代码到底在做什么事情,以及 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"match"}]},{"type":"text","value":" 方法在做什么"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":" this.matcher = createMatcher(options.routes || [], this)\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"matcher "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"createMatcher"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"(options"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"routes "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"||"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" []"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"首先将代码定位到 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"create-matcher.js"}]}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"export function createMatcher (\n  routes: Array<RouteConfig>,\n  router: VueRouter\n): Matcher {\n  // 创建映射表\n  const { pathList, pathMap, nameMap } = createRouteMap(routes)\n\n  function addRoutes(routes){...}\n\n  function match (\n    raw: RawLocation,\n    currentRoute?: Route,\n    redirectedFrom?: Location\n  ): Route {...}\n\n  function redirect (\n    record: RouteRecord,\n    location: Location\n  ): Route {...}\n\n  function alias (\n    record: RouteRecord,\n    location: Location,\n    matchAs: string\n  ): Route {...}\n\n  function _createRoute (\n    record: ?RouteRecord,\n    location: Location,\n    redirectedFrom?: Location\n  ): Route {...}\n\n  function matchRoute (\n    regex: RouteRegExp,\n    path: string,\n    params: Object\n  ): boolean {...}\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"createMatcher"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  routes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Array"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"RouteConfig"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">,"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  router"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"VueRouter"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"):"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Matcher"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 创建映射表"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"pathList"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"pathMap"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"nameMap"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"createRouteMap"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"routes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"addRoutes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"routes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"){...}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"match"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"raw"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"RawLocation"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"currentRoute"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"?:"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"redirectedFrom"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"?:"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Location"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"):"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{...}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"redirect"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"record"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"RouteRecord"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"location"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Location"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"):"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{...}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"alias"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"record"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"RouteRecord"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"location"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Location"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"matchAs"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"string"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"):"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{...}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"_createRoute"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"record"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"?"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"RouteRecord"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"location"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Location"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"redirectedFrom"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"?:"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Location"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"):"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{...}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"matchRoute"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"regex"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"RouteRegExp"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"string"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"params"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Object"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"):"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"boolean"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{...}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"createMatcher"}]},{"type":"text","value":" 接受俩参数,分别是 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"routes"}]},{"type":"text","value":" ,这个就是我们平时在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"router.js"}]},{"type":"text","value":" 定义的路由表配置，然后还有一个参数是 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"router"}]},{"type":"text","value":" 他是 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"new vueRouter"}]},{"type":"text","value":" 返回的实例。"}]},{"type":"element","tag":"h2","props":{"id":"create-route-map"},"children":[{"type":"text","value":"create-route-map"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"下面这句代码是在创建一张 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"path-record"}]},{"type":"text","value":","},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"name-record"}]},{"type":"text","value":" 的映射表，我们将代码定位到 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"create-route-map.js"}]}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"export function createRouteMap (\n  routes: Array<RouteConfig>,\n  oldPathList?: Array<string>,\n  oldPathMap?: Dictionary<RouteRecord>,\n  oldNameMap?: Dictionary<RouteRecord>\n): {\n  pathList: Array<string>,\n  pathMap: Dictionary<RouteRecord>,\n  nameMap: Dictionary<RouteRecord>\n} {\n  // debugger\n  // 记录所有的 path\n  const pathList: Array<string> = oldPathList || []\n  // 记录 path-RouteRecord 的 Map\n  const pathMap: Dictionary<RouteRecord> = oldPathMap || Object.create(null)\n   // 记录 path-RouteRecord 的 Map\n  const nameMap: Dictionary<RouteRecord> = oldNameMap || Object.create(null)\n  // 遍历所有的 route 生成对应映射表\n  routes.forEach(route => {\n    addRouteRecord(pathList, pathMap, nameMap, route)\n  })\n  // 调整优先级\n  for (let i = 0, l = pathList.length; i < l; i++) {\n    if (pathList[i] === '*') {\n      pathList.push(pathList.splice(i, 1)[0])\n      l--\n      i--\n    }\n  }\n\n  return {\n    pathList,\n    pathMap,\n    nameMap\n  }\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"createRouteMap"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  routes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Array"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"RouteConfig"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">,"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  oldPathList"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"?:"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Array"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"string"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">,"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  oldPathMap"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"?:"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Dictionary"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"RouteRecord"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">,"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  oldNameMap"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"?:"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Dictionary"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"RouteRecord"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"):"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"pathList"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Array"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"string"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">,"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"pathMap"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Dictionary"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"RouteRecord"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">,"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"nameMap"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Dictionary"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"RouteRecord"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// debugger"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 记录所有的 path"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"pathList"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Array"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"string"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"oldPathList"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"||"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" []"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 记录 path-RouteRecord 的 Map"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"pathMap"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Dictionary"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"RouteRecord"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"oldPathMap"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"||"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Object"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"create"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"null"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"   "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 记录 path-RouteRecord 的 Map"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"nameMap"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Dictionary"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"RouteRecord"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"oldNameMap"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"||"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Object"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"create"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"null"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 遍历所有的 route 生成对应映射表"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"routes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"forEach"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"addRouteRecord"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"pathList"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"pathMap"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"nameMap"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 调整优先级"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"for"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"let"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"i"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"0"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"l"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"pathList"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"length"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"i"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"l"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"i"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"++"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"pathList"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"["}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"i"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"] "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"==="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"*"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"pathList"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"push"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"pathList"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"splice"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"i"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"1"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")["}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"0"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"])"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"l"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"--"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"i"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"--"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"pathList"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"pathMap"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"nameMap"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"createRouteMap"}]},{"type":"text","value":" 需要传入路由配置，支持传入旧路径数组和旧的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Map"}]},{"type":"text","value":"这一步是为后面递归和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"addRoutes"}]},{"type":"text","value":" 做好准备。 首先用三个变量记录 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"path"}]},{"type":"text","value":" ,"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"pathMap"}]},{"type":"text","value":","},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"nameMap"}]},{"type":"text","value":" ，接着我们来看 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"addRouteRecord"}]},{"type":"text","value":" 这个核心方法"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"这一块代码太多了，列举几个重要的步骤"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"const pathToRegexpOptions: PathToRegexpOptions =\n    route.pathToRegexpOptions || {}\n    \nconst normalizedPath = normalizePath(path, parent, pathToRegexpOptions.strict)\n\nconst record: RouteRecord = {\n  path: normalizedPath,\n  regex: compileRouteRegex(normalizedPath, pathToRegexpOptions),\n  // route对应的组件\n  components: route.components || { default: route.component },\n  // 组件实例\n  instances: {},\n  name,\n  parent,\n  matchAs,\n  redirect: route.redirect,\n  beforeEnter: route.beforeEnter,\n  meta: route.meta || {},\n  props: route.props == null\n    ? {}\n    : route.components\n      ? route.props\n      : { default: route.props }\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" pathToRegexpOptions"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"PathToRegexpOptions"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"pathToRegexpOptions "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"||"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" normalizedPath "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"normalizePath"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"(path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" parent"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" pathToRegexpOptions"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"strict)"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" record"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"RouteRecord"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" normalizedPath"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"regex"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"compileRouteRegex"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"(normalizedPath"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" pathToRegexpOptions)"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// route对应的组件"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"components"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"components "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"||"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"component "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 组件实例"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"instances"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  name"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  parent"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  matchAs"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"redirect"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"redirect"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"beforeEnter"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"beforeEnter"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"meta"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"meta "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"||"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"props"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"props "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"=="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"null"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"?"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"components"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"?"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"props"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"props "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"使用 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"recod"}]},{"type":"text","value":" 记录路由配置有利于后续路径切换时计算出新路径，这里的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"path"}]},{"type":"text","value":" 其实是通过 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"path"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"parent"}]},{"type":"text","value":" 拼接处的路径。然后 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"regex"}]},{"type":"text","value":" 使用一个库将 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"path"}]},{"type":"text","value":" 解析为正则表达式。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"如果 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"route"}]},{"type":"text","value":" 有子节点就递归调用 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"addRouteRecord"}]}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":" // 如果有children 递归调用addRouteRecord\n    route.children.forEach(child => {\n      const childMatchAs = matchAs\n        ? cleanPath(`${matchAs}/${child.path}`)\n        : undefined\n      addRouteRecord(pathList, pathMap, nameMap, child, record, childMatchAs)\n    })\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 如果有children 递归调用addRouteRecord"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"children"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"forEach"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"(child "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"childMatchAs"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"matchAs"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"?"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"cleanPath"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"`${"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"matchAs"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"${"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"child"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}`"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"undefined"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"addRouteRecord"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"pathList"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"pathMap"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"nameMap"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"child"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"record"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"childMatchAs"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"最后映射一张表,并将 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"record·path"}]},{"type":"text","value":" 保存进 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"pathList"}]},{"type":"text","value":", "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"nameMap"}]},{"type":"text","value":" 逻辑相似就不列举了"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"  if (!pathMap[record.path]) {\n    pathList.push(record.path)\n    pathMap[record.path] = record\n  }\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"!"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"pathMap[record"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"path]) "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"pathList"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"push"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"record"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"pathMap"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"["}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"record"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"] "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"record"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"废了这么大劲将 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"pathList"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"pathMap"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"nameMap"}]},{"type":"text","value":" 抽出来是为啥呢，首先 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"pathList"}]},{"type":"text","value":" 是记录路由配置所有的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"path"}]},{"type":"text","value":"，然后 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"pathMap"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"nameMap"}]},{"type":"text","value":" 方便我们传入 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"path"}]},{"type":"text","value":" 或者 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"name"}]},{"type":"text","value":" 快速定位到一个 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"record"}]},{"type":"text","value":" ,然后辅助后续路径切换计算路由滴。"}]},{"type":"element","tag":"h2","props":{"id":"addroutes"},"children":[{"type":"text","value":"addRoutes"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"这是在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vue2.2.0"}]},{"type":"text","value":" 之后新添加的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"api"}]},{"type":"text","value":" ,或许很多情况路由并不是写死的，需要动态添加路由。有了前面的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"createRouteMap"}]},{"type":"text","value":" 的基础上我们只需要传入 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"routes"}]},{"type":"text","value":" 、"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"pathList"}]},{"type":"text","value":"、 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"pathMap"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"nameMap"}]},{"type":"text","value":" 即可，他就能在原基础上修改"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"function addRoutes (routes) {\n  createRouteMap(routes, pathList, pathMap, nameMap)\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"addRoutes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"routes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"createRouteMap"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"routes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"pathList"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"pathMap"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"nameMap"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"并且看到在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"createMathcer"}]},{"type":"text","value":" 最后返回了这个方法，所以我们就可以使用这个方法"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"return {\n    match,\n    addRoutes\n  }\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    match"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    addRoutes"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"h2","props":{"id":"match"},"children":[{"type":"text","value":"match"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"function match (\n  raw: RawLocation,\n  currentRoute?: Route,\n  redirectedFrom?: Location\n): Route {\n  ...\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"match"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  raw"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"RawLocation"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  currentRoute"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"?:"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  redirectedFrom"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"?:"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Location"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"):"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"..."}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"接下来就是 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"match"}]},{"type":"text","value":" 方法，它接收 3 个参数，其中 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"raw"}]},{"type":"text","value":" 是 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"RawLocation"}]},{"type":"text","value":" 类型，它可以是一个 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"url"}]},{"type":"text","value":" 字符串，也可以是一个 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Location"}]},{"type":"text","value":" 对象；"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"currentRoute"}]},{"type":"text","value":" 是 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Route"}]},{"type":"text","value":" 类型，它表示当前的路径；"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"redirectedFrom"}]},{"type":"text","value":" 和重定向相关。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"match"}]},{"type":"text","value":" 方法返回的是一个路径，它的作用是根据传入的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"raw"}]},{"type":"text","value":" 和当前的路径 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"currentRoute"}]},{"type":"text","value":" 计算出一个新的路径并返回。至于他是如何计算出这条路径的可以详细看一下如何计算出 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"location"}]},{"type":"text","value":" 的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"normalizeLocation"}]},{"type":"text","value":" 方法和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"match"}]},{"type":"text","value":" 方法后面的逻辑。"}]},{"type":"element","tag":"h2","props":{"id":"总结-2"},"children":[{"type":"text","value":"总结"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"createMatcher"}]},{"type":"text","value":": 根据路由的配置描述建立映射表，包括路径、名称到路由 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"record"}]},{"type":"text","value":" 的映射关系, 最重要的就是 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"create-route-map"}]},{"type":"text","value":" 这个方法，这里也是动态路由匹配和嵌套路由的原理。"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"addRoutes"}]},{"type":"text","value":": 动态添加路由配置"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"match"}]},{"type":"text","value":": 根据传入的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"raw"}]},{"type":"text","value":" 和当前的路径 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"currentRoute"}]},{"type":"text","value":" 计算出一个新的路径并返回。"}]}]},{"type":"element","tag":"h2","props":{"id":"路由模式"},"children":[{"type":"text","value":"路由模式"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vue-router"}]},{"type":"text","value":" 支持三种路由模式(mode)："},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"hash"}]},{"type":"text","value":"、"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"history"}]},{"type":"text","value":"、"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"abstract"}]},{"type":"text","value":"，其中 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"abstract"}]},{"type":"text","value":" 是在非浏览器环境下使用的路由模式"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"这一部分在前面初始化 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vueRouter"}]},{"type":"text","value":" 对象时提到过,首先会拿配置项的模式 ，然后根据当前传入的配置判断当前浏览器是否支持这种模式，默认"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"ie9"}]},{"type":"text","value":" 以下会降级为 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"hash"}]},{"type":"text","value":"。 然后根据不同的模式去初始化不同的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"history"}]},{"type":"text","value":" 实例。"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"// 一般分两种模式 hash和history路由 第三种是抽象模式\n    let mode = options.mode || 'hash'\n    // 判断当前传入的配置是否能使用history模式\n    this.fallback = mode === 'history' && !supportsPushState && options.fallback !== false\n    // 降级处理\n    if (this.fallback) {\n      mode = 'hash'\n    }\n    if (!inBrowser) {\n      mode = 'abstract'\n    }\n    this.mode = mode\n\n    // 根据模式实例化不同的history history对象会对路由进行管理 继承于history class\n    switch (mode) {\n      case 'history':\n        this.history = new HTML5History(this, options.base)\n        break\n      case 'hash':\n        this.history = new HashHistory(this, options.base, this.fallback)\n        break\n      case 'abstract':\n        this.history = new AbstractHistory(this, options.base)\n        break\n      default:\n        if (process.env.NODE_ENV !== 'production') {\n          assert(false, `invalid mode: ${mode}`)\n        }\n    }\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 一般分两种模式 hash和history路由 第三种是抽象模式"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"let"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" mode "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" options"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"mode "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"||"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"hash"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 判断当前传入的配置是否能使用history模式"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"fallback "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" mode "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"==="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"history"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"&&"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"!"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"supportsPushState "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"&&"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" options"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"fallback "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"!=="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"false"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 降级处理"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"fallback) "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"mode"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"hash"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"!"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"inBrowser) "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"mode"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"abstract"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"mode "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" mode"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 根据模式实例化不同的history history对象会对路由进行管理 继承于history class"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"switch"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" (mode) "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"case"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"history"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"history "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"new"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"HTML5History"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this,"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" options"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"base)"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"break"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"case"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"hash"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"history "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"new"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"HashHistory"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this,"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" options"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"base"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"fallback)"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"break"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"case"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"abstract"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"history "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"new"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"AbstractHistory"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this,"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" options"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"base)"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"break"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" (process"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"env"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"NODE_ENV "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"!=="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"production"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"          "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"assert"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"false"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"`"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"invalid mode: "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"${"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"mode"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}`"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"h2","props":{"id":"总结-3"},"children":[{"type":"text","value":"总结"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vue-router"}]},{"type":"text","value":" 支持三种路由模式，"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"hash"}]},{"type":"text","value":"、"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"history"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"abstract"}]},{"type":"text","value":" 。默认为 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"hash"}]},{"type":"text","value":" ,如果当前浏览器不支持 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"history"}]},{"type":"text","value":" 则会做降级处理，然后完成 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"history"}]},{"type":"text","value":"的初始化。"}]},{"type":"element","tag":"h2","props":{"id":"router-view--router-link"},"children":[{"type":"text","value":"router-view & router-link"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vue-router"}]},{"type":"text","value":" 在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" 时全局注册了两个组件一个是 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"router-view"}]},{"type":"text","value":" 一个是 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"router-link"}]},{"type":"text","value":" ，这俩个组件都是典型的函数式组件。"}]},{"type":"element","tag":"h2","props":{"id":"router-view"},"children":[{"type":"text","value":"router-view"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"首先在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"router"}]},{"type":"text","value":" 组件执行 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"beforeCreate"}]},{"type":"text","value":" 这个钩子时，把 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"this._route"}]},{"type":"text","value":" 转为了响应式的一个对象"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":" Vue.util.defineReactive(this, '_route', this._router.history.current)\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" Vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"util"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"defineReactive"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this,"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"_route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"_router"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"history"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"current)"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"所以说每次路由切换都会触发 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"router-view"}]},{"type":"text","value":" 重新 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"render"}]},{"type":"text","value":" 从而渲染出新的视图。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"核心的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"render"}]},{"type":"text","value":" 函数作用请看代码注释"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"  render (_, { props, children, parent, data }) {\n    // 标志\n    data.routerView = true\n    // 获取跟 dom\n    const h = parent.$createElement\n    const name = props.name\n    // 注册时定义的原型 $route 可以理解成当前路径\n    const route = parent.$route\n    // 缓存相关\n    const cache = parent._routerViewCache || (parent._routerViewCache = {})\n    \n    // 通过 depth 由router-view组件向上遍历直到跟组件，遇到其他的router-view组件则路由深度+1\n    let depth = 0\n    let inactive = false\n    while (parent && parent._routerRoot !== parent) {\n      // parent.$vnode.data.routerView 为 true 则代表向上寻找的组件也存在嵌套的 router-view \n      if (parent.$vnode && parent.$vnode.data.routerView) {\n        depth++\n      }\n      if (parent._inactive) {\n        inactive = true\n      }\n      parent = parent.$parent\n    }\n    data.routerViewDepth = depth\n\n    if (inactive) {\n      return h(cache[name], data, children)\n    }\n\n   // 通过 matched 记录寻找出对应的 RouteRecord \n    const matched = route.matched[depth]\n    if (!matched) {\n      cache[name] = null\n      return h()\n    }\n // 通过 RouteRecord 找到 component\n    const component = cache[name] = matched.components[name]\n   \n   // 往父组件注册registerRouteInstance方法\n    data.registerRouteInstance = (vm, val) => {     \n      const current = matched.instances[name]\n      if (\n        (val && current !== vm) ||\n        (!val && current === vm)\n      ) {\n        matched.instances[name] = val\n      }\n    }\n  // 渲染组件\n    return h(component, data, children)\n  }\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"render"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" (_"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" props"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" children"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" parent"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" data "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 标志"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"data"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"routerView"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"true"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 获取跟 dom"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"h"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"parent"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$createElement"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"name"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"props"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"name"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 注册时定义的原型 $route 可以理解成当前路径"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"parent"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$route"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 缓存相关"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"cache"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"parent"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"_routerViewCache"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"||"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"parent"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"_routerViewCache"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 通过 depth 由router-view组件向上遍历直到跟组件，遇到其他的router-view组件则路由深度+1"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"let"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"depth"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"0"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"let"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"inactive"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"false"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"while"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"parent"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"&&"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"parent"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"_routerRoot"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"!=="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"parent"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// parent.$vnode.data.routerView 为 true 则代表向上寻找的组件也存在嵌套的 router-view "}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"parent"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$vnode"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"&&"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"parent"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$vnode"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"data"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"routerView"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"depth"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"++"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"parent"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"_inactive"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"inactive"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"true"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"parent"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"parent"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$parent"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"data"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"routerViewDepth"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"depth"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"inactive"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"h"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"cache"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"["}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"name"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"data"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"children"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"   "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 通过 matched 记录寻找出对应的 RouteRecord "}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"matched"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"matched"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"["}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"depth"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"]"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"!"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"matched"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"cache"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"["}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"name"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"] "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"null"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"h"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"()"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 通过 RouteRecord 找到 component"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"component"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"cache"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"["}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"name"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"] "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"matched"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"components"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"["}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"name"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"]"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"   "}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"   "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 往父组件注册registerRouteInstance方法"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"data"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"registerRouteInstance"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"vm"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"val"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"     "}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"current"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"matched"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"instances"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"["}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"name"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"]"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"val"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"&&"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"current"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"!=="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"vm"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"||"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"!"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"val"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"&&"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"current"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"==="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"vm"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      ) "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"matched"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"instances"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"["}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"name"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"] "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"val"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 渲染组件"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"h"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"component"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"data"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"children"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"触发更新也就是 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"setter"}]},{"type":"text","value":" 的调用，位于 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"src/index.js"}]}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"history.listen(route => {\n  this.apps.forEach((app) => {\n    // 触发 setter\n    app._route = route\n  })\n})\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"history"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"listen"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"(route "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"apps"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"forEach"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"app"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 触发 setter"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"app"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"_route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"route"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]}]}]}]}]}]},{"type":"element","tag":"h2","props":{"id":"router-link"},"children":[{"type":"text","value":"router-link"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"分析几个重要的部分"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"设置 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"active"}]},{"type":"text","value":" 路由样式"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"router-link"}]},{"type":"text","value":" 之所以可以添加 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"router-link-active"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"router-link-exact-active"}]},{"type":"text","value":" 这两个 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"class"}]},{"type":"text","value":" 去修改样式，是因为在执行 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"render"}]},{"type":"text","value":" 函数时，会根据当前的路由状态，给渲染出来的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"active"}]},{"type":"text","value":" 元素添加 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"class"}]}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"render (h: Function) {\n  ...\n  const globalActiveClass = router.options.linkActiveClass\n  const globalExactActiveClass = router.options.linkExactActiveClass\n  // Support global empty active class\n  const activeClassFallback = globalActiveClass == null\n    ? 'router-link-active'\n    : globalActiveClass\n  const exactActiveClassFallback = globalExactActiveClass == null\n    ? 'router-link-exact-active'\n    : globalExactActiveClass\n    ...\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"render"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" (h: "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"..."}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"globalActiveClass"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"router"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"options"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"linkActiveClass"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"globalExactActiveClass"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"router"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"options"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"linkExactActiveClass"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// Support global empty active class"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"activeClassFallback"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"globalActiveClass"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"=="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"null"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"?"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"router-link-active"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"globalActiveClass"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"exactActiveClassFallback"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"globalExactActiveClass"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"=="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"null"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"?"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"router-link-exact-active"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"globalExactActiveClass"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"..."}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"router-link"}]},{"type":"text","value":" 默认渲染为 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"a"}]},{"type":"text","value":" 标签，如果不是会去向上查找出第一个 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"a"}]},{"type":"text","value":" 标签"}]}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":" if (this.tag === 'a') {\n      data.on = on\n      data.attrs = { href }\n    } else {\n      // find the first <a> child and apply listener and href\n      const a = findAnchor(this.$slots.default)\n      if (a) {\n        // in case the <a> is a static node\n        a.isStatic = false\n        const aData = (a.data = extend({}, a.data))\n        aData.on = on\n        const aAttrs = (a.data.attrs = extend({}, a.data.attrs))\n        aAttrs.href = href\n      } else {\n        // 不存在则渲染本身元素\n        data.on = on\n      }\n    }\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"tag "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"==="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"a"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"data"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"on"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"on"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"data"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"attrs"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"href"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"else"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// find the first <a> child and apply listener and href"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"a"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"findAnchor"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"$slots"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"a"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// in case the <a> is a static node"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"a"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"isStatic"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"false"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"aData"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"a"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"data"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"extend"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{},"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"a"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"data"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"))"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"aData"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"on"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"on"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"aAttrs"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"a"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"data"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"attrs"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"extend"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{},"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"a"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"data"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"attrs"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"))"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"aAttrs"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"href"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"href"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"else"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 不存在则渲染本身元素"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"data"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"on"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"on"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"切换路由，触发相应事件"}]}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"const handler = e => {\n  if (guardEvent(e)) {\n    if (this.replace) {\n      // replace路由\n      router.replace(location)\n    } else {\n      // push 路由\n      router.push(location)\n    }\n  }\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" handler "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" e "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"guardEvent"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"e"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")) "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"replace"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// replace路由"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"router"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"replace"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"location"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"else"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// push 路由"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"router"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"push"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"location"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"h2","props":{"id":"权限控制动态路由原理分析"},"children":[{"type":"text","value":"权限控制动态路由原理分析"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"我相信，开发过后台项目的同学经常会碰到以下的场景: 一个系统分为不同的角色，然后不同的角色对应不同的操作菜单和操作权限。例如: 教师可以查询教师自己的个人信息查询然后还可以查询操作学生的信息和学生的成绩系统、学生用户只允许查询个人成绩和信息，不允许更改。在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vue2.2.0"}]},{"type":"text","value":" 之前还没有加入 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"addRoutes"}]},{"type":"text","value":" 这个 API 是十分困难的的。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"目前主流的路由权限控制的方式是:"}]},{"type":"element","tag":"ol","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"前端在登录之后获取到 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"JWT 令牌"}]},{"type":"text","value":" 前端在全局路由拦截,并在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"route.js"}]},{"type":"text","value":" 定义一套前端的路由表"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"后端根据登录信息返回给前端对应的身份信息，并且涉及到身份信息操作的接口都需要做身份校验处理。 当然这里也可以在数据库中提前定义好一张 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"roles-router"}]},{"type":"text","value":" 表,然后在查询用户信息时将对应的路由树状表返给前端"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"前端根据当前的角色将对应的权限的路由表拼接到常规路由表后面"}]}]},{"type":"element","tag":"h3","props":{"id":"登录生成动态路由全过程"},"children":[{"type":"text","value":"登录生成动态路由全过程"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"了解如何控制动态路由之后，下面是我画的一张全过程流程图\n"},{"type":"element","tag":"Image","props":{"alt":"","src":"//p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/cf68a840ca31484c985517c869e2873c~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"前端在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"beforeEach"}]},{"type":"text","value":" 中判断:"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"缓存中存在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"JWT令牌"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"访问 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"/login"}]},{"type":"text","value":" : 重定向到首页"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"('/')"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"访问 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"/login"}]},{"type":"text","value":" 以外的路由:  首次访问，获取用户角色信息，然后生成动态路由，然后访问以 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"replace"}]},{"type":"text","value":" 模式访问 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"/xxx"}]},{"type":"text","value":" 路由。这种模式用户在登录之后不会在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"history"}]},{"type":"text","value":" 存放记录，回退直接显示空白页面"}]}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"不存在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"JWT令牌"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"路由在白名单中: 正常访问 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"/xxx"}]},{"type":"text","value":" 路由"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"不在白名单中: 重定向到 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"/login"}]},{"type":"text","value":" 页面"}]}]}]}]},{"type":"element","tag":"h3","props":{"id":"结合框架源码分析"},"children":[{"type":"text","value":"结合框架源码分析"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"下面结合 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vue-element-admin"}]},{"type":"text","value":" 的源码分析该框架中如何处理路由逻辑的。"}]},{"type":"element","tag":"h3","props":{"id":"路由访问逻辑分析"},"children":[{"type":"text","value":"路由访问逻辑分析"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"首先可以定位到和入口文件 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"main.js"}]},{"type":"text","value":" 同级的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"permission.js"}]},{"type":"text","value":" , 全局路由守卫处理就在此"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"const whiteList = ['/login', '/register'] // 路由白名单，不会重定向\n\n// 全局路由守卫\nrouter.beforeEach(async(to, from, next) => {\n  NProgress.start() //路由加载进度条\n  // 设置meta标题\n  document.title = getPageTitle(to.meta.title)\n  // 判断token是否存在\n  const hasToken = getToken()\n  if (hasToken) {\n    if (to.path === '/login') {\n      // 有token 跳转首页\n      next({ path: '/' })\n      NProgress.done()\n    } else {\n      const hasRoles = store.getters.roles && store.getters.roles.length > 0\n      if (hasRoles) {\n        next()\n      } else {\n        try {\n          // 获取动态路由，添加到路由表中\n          const { roles } = await store.dispatch('user/getInfo')\n          const accessRoutes = await store.dispatch('permission/generateRoutes', roles)\n          router.addRoutes(accessRoutes)\n          //  使用 replace 访问路由，不会在 history 中留下记录，登录到dashbord时回退空白页面\n          next({ ...to, replace: true })\n        } catch (error) {\n          next('/login')\n          NProgress.done()\n        }\n      }\n    }\n  } else {\n    // 无token\n    // 白名单不用重定向 直接访问\n    if (whiteList.indexOf(to.path) !== -1) {\n      next()\n    } else {\n      // 携带参数为重定向到前往的路径\n      next(`/login?redirect=${to.path}`)\n      NProgress.done()\n    }\n  }\n})\n\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" whiteList "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ["}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/login"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/register"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"] "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 路由白名单，不会重定向"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 全局路由守卫"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"router"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"beforeEach"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"async"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"to"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" next"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"NProgress"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"start"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"() "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//路由加载进度条"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 设置meta标题"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"document"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"title"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"getPageTitle"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"to"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"meta"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"title"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 判断token是否存在"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"hasToken"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"getToken"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"()"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"hasToken"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"to"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"==="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/login"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 有token 跳转首页"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"next"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"NProgress"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"done"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"()"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"else"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"hasRoles"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"store"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"getters"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"roles"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"&&"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"store"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"getters"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"roles"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"length"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"0"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"hasRoles"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"next"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"()"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"else"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"try"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"          "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 获取动态路由，添加到路由表中"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"          "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"roles"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"await"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"store"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"dispatch"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"user/getInfo"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"          "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"accessRoutes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"await"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"store"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"dispatch"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"permission/generateRoutes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"roles"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"          "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"router"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"addRoutes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"accessRoutes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"          "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//  使用 replace 访问路由，不会在 history 中留下记录，登录到dashbord时回退空白页面"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"          "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"next"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"..."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"to"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" replace"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"true"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"catch"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"error"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"          "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"next"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/login"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"          "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"NProgress"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"done"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"()"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"else"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 无token"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 白名单不用重定向 直接访问"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"whiteList"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"indexOf"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"to"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"!=="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"-"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"1"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"next"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"()"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"else"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 携带参数为重定向到前往的路径"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"next"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"`"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/login?redirect="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"${"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"to"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}`"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"NProgress"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"done"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"()"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"这里的代码我都添加了注释方便大家好去理解，总结为一句话就是访问路由 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"/xxx"}]},{"type":"text","value":" ，首先需要校验 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"token"}]},{"type":"text","value":"是否存在，如果有就判断是否访问的是登录路由，不是则需要判断该用户是否是第一访问首页，然后生成动态路由，如果没有 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"token"}]},{"type":"text","value":" 就去检查路由是否在白名单(任何情况都能访问的路由)，在的话就访问，否则重定向回登录页面。"}]},{"type":"element","tag":"h3","props":{"id":"结合vuex生成动态路由"},"children":[{"type":"text","value":"结合Vuex生成动态路由"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"下面就是分析这一步 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"const accessRoutes = await store.dispatch('permission/generateRoutes', roles)"}]},{"type":"text","value":" 是怎么把路由生成出来的。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"首选 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vue-element-admin"}]},{"type":"text","value":" 中路由是分为两种的:"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"constantRoutes: 不需要权限判断的路由"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"asyncRoutes: 需要动态判断权限的路由"}]}]},{"type":"element","tag":"Image","props":{"alt":"","src":"//p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/152acc3571074c03af839fbf00b5ac45~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"生成动态路由的源码位于 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"src/store/modules/permission.js"}]},{"type":"text","value":" 中的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"generateRoutes"}]},{"type":"text","value":" 方法，源码如下："}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":" generateRoutes({ commit }, roles) {\n    return new Promise(resolve => {\n      //   debugger\n      let accessedRoutes\n      if (roles.includes('admin')) {\n        accessedRoutes = asyncRoutes || []\n      } else {\n      // 不是admin 去遍历生成对应的权限路由表\n        accessedRoutes = filterAsyncRoutes(asyncRoutes, roles)\n      }\n      commit('SET_ROUTES', accessedRoutes)\n      resolve(accessedRoutes)\n    })\n  }\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"generateRoutes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" commit "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" roles) "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"new"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Promise"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"resolve"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//   debugger"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"let"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"accessedRoutes"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"roles"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"includes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"admin"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")) "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"accessedRoutes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"asyncRoutes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"||"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" []"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"else"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 不是admin 去遍历生成对应的权限路由表"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"accessedRoutes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"filterAsyncRoutes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"asyncRoutes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"roles"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"commit"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"SET_ROUTES"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"accessedRoutes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"resolve"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"accessedRoutes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"从 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"route.js"}]},{"type":"text","value":" 读取 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"asyncRoutes"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"constantRoutes"}]},{"type":"text","value":" 之后首先判断当前角色是否是 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"admin"}]},{"type":"text","value":" ，是的话默认超级管理员能够访问所有的路由，当然这里也可以自定义，否则去过滤出路由权限路由表，然后保存到"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vuex"}]},{"type":"text","value":"中。 最后将过滤之后的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"asyncRoutes"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"constantRoutes"}]},{"type":"text","value":" 进行合并。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"过滤权限路由的源码如下:"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"export function filterAsyncRoutes(routes, roles) {\n  const res = []\n  routes.forEach(route => {\n    // 浅拷贝\n    const tmp = { ...route }\n    if (hasPermission(roles, tmp)) {\n      if (tmp.children) {\n        tmp.children = filterAsyncRoutes(tmp.children, roles)\n      }\n      res.push(tmp)\n    }\n  })\n  return res\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"filterAsyncRoutes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"routes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" roles"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"res"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" []"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"routes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"forEach"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 浅拷贝"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"tmp"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"..."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"hasPermission"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"roles"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"tmp"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")) "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"tmp"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"children"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"tmp"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"children"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"filterAsyncRoutes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"tmp"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"children"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"roles"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"res"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"push"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"tmp"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"res"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"首先定义一个空数组，对传入 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"asyncRoutes"}]},{"type":"text","value":" 进行遍历，判断每个路由是否具有权限，未命中的权限路由直接舍弃\n判断权限方法如下:"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"function hasPermission(roles, route) {\n  if (route.meta && route.meta.roles) {\n    // roles有对应路由元定义的role 就返回true\n    return roles.some(role => route.meta.roles.includes(role))\n  } else {\n    return true\n  }\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"hasPermission"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"roles"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"meta"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"&&"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"meta"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"roles"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// roles有对应路由元定义的role 就返回true"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"roles"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"some"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"role"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"route"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"meta"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"roles"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"includes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"role"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"))"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"else"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"true"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"接着需要判断二级路由、三级路由等等的情况，再做一层迭代处理，最后将过滤出来的路由推进数组返回。然后追加到 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"constantRoutes"}]},{"type":"text","value":"后面"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":" SET_ROUTES: (state, routes) => {\n    state.addRoutes = routes\n    state.routes = constantRoutes.concat(routes)\n  }\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"SET_ROUTES"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"state"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" routes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"state"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"addRoutes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"routes"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"state"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"routes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"constantRoutes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"concat"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"routes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"动态路由生成全过程"}]}]},{"type":"element","tag":"Image","props":{"alt":"","src":"//p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/532453ffff994b01a5f3d9c70737be1f~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]},{"type":"element","tag":"h2","props":{"id":"总结-4"},"children":[{"type":"text","value":"总结"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vue-router"}]},{"type":"text","value":"源码"},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"注册: 执行 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"install"}]},{"type":"text","value":" 方法，注入生命周期钩子初始化"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"vueRouter: 当组件执行 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"beforeCreate"}]},{"type":"text","value":" 传入 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"router"}]},{"type":"text","value":" 实例时,执行 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"init"}]},{"type":"text","value":" 函数，然后执行 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"history.transitionTo"}]},{"type":"text","value":" 路由过渡"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"matcher : 根据传入的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"routes"}]},{"type":"text","value":" 配置创建对应的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"pathMap"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"nameMap"}]},{"type":"text","value":",可以根据传入的位置和路径计算出新的位置并匹配对应的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"record"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"router-view: 调用父组件上存储的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"$route.match"}]},{"type":"text","value":" 控制路由对应的组件的渲染情况，并且支持嵌套。"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"router-link: 通过 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"to"}]},{"type":"text","value":" 来决定点击事件跳转的目标路由组件，并且支持渲染成不同的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"tag"}]},{"type":"text","value":",还可以修改激活路由的样式。"}]}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"权限控制动态路由:"},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"路由逻辑: 全局路由拦截，从缓存中获取令牌，存在的话如果首次进入路由需要获取用户信息，生成动态路由，这里需要处理 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"/login"}]},{"type":"text","value":" 特殊情况，不存在则判断白名单然后走对应的逻辑"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"动态生成路由: 传入需要 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"router.js"}]},{"type":"text","value":" 定义的两种路由。判断当前身份是否是管理员，是则直接拼接，否则需要过滤出具备权限的路由，最后拼接到常规路由后面，通过 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"addRoutes"}]},{"type":"text","value":" 追加。"}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"个人感悟"}]},{"type":"text","value":":"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"或许阅读源码的作用不能像一些文档一样直接立马对日常开发有所帮助，但是它的影响是长远的，在读源码的过程中都可以学到类似闭包、设计模式、时间循环、回调等等 JS 进阶技能，并稳固并提升了你的 JS 基础。当然这篇文章缺陷的，有几个地方都没有分析到，比如导航守卫实现原理和路由懒加载实现原理，这一部分，我还在摸索当中。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"如果一味的死记硬背一些所谓的面经，或者直接死记硬背相关的框架行为或者 API ，你很难在遇到比较复杂的问题下面去快速定位问题，解怎么去解决问题，而且我发现很多人在使用一个新框架之后遇到点问题都会立马去提对应的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Issues"}]},{"type":"text","value":" ,但是许多问题都是因为我们并未按照设计者开发初设定的方向才导致错误的，更多都是些粗心大意造成的问题。"}]},{"type":"element","tag":"blockquote","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"参考文章"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://juejin.im/post/6844904064367460366","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"带你全面分析vue-router源码 (万字长文)"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/answershuto/learnVue","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"vuejs 源码解析"}]}]}]}],"toc":{"title":"","searchDepth":2,"depth":2,"links":[{"id":"前置知识-flow-语法","depth":2,"text":"前置知识: flow 语法"},{"id":"注册","depth":2,"text":"注册"},{"id":"vueuse","depth":2,"text":"Vue.use"},{"id":"install","depth":2,"text":"install"},{"id":"总结","depth":2,"text":"总结"},{"id":"vuerouter","depth":2,"text":"vueRouter"},{"id":"构造函数","depth":2,"text":"构造函数"},{"id":"init","depth":2,"text":"init"},{"id":"总结-1","depth":2,"text":"总结"},{"id":"matcher","depth":2,"text":"matcher"},{"id":"create-route-map","depth":2,"text":"create-route-map"},{"id":"addroutes","depth":2,"text":"addRoutes"},{"id":"match","depth":2,"text":"match"},{"id":"总结-2","depth":2,"text":"总结"},{"id":"路由模式","depth":2,"text":"路由模式"},{"id":"总结-3","depth":2,"text":"总结"},{"id":"router-view--router-link","depth":2,"text":"router-view & router-link"},{"id":"router-view","depth":2,"text":"router-view"},{"id":"router-link","depth":2,"text":"router-link"},{"id":"权限控制动态路由原理分析","depth":2,"text":"权限控制动态路由原理分析","children":[{"id":"登录生成动态路由全过程","depth":3,"text":"登录生成动态路由全过程"},{"id":"结合框架源码分析","depth":3,"text":"结合框架源码分析"},{"id":"路由访问逻辑分析","depth":3,"text":"路由访问逻辑分析"},{"id":"结合vuex生成动态路由","depth":3,"text":"结合Vuex生成动态路由"}]},{"id":"总结-4","depth":2,"text":"总结"}]}},"_type":"markdown","_id":"content:posts:learn-vue-router.md","_source":"content","_file":"posts/learn-vue-router.md","_extension":"md","storageMeta":{"atime":"2023-06-16T10:26:05.626Z","mtime":"2023-06-16T10:26:05.626Z","size":31988},"readingMins":4,"path":"/blog/learn-vue-router","renderer":"post","schemaOrg":{"modifiedAt":"2023-06-16T10:26:05.626Z"},"modifiedAt":"2023-06-16T10:26:05.626Z"},{"_path":"/posts/modern-package-development","_draft":false,"_partial":false,"_empty":false,"title":"Learning Modern Package Development: Monorepos and Backends - Part 1","description":"Discover how you can build a modern package development through how I created the Unlighthouse project.","excerpt":{"type":"root","children":[{"type":"element","tag":"toc","props":{},"children":[]},{"type":"element","tag":"primary","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"This article is a work in progress. Feel free to read it, but some sections are incomplete."}]}]},{"type":"element","tag":"h2","props":{"id":"introduction"},"children":[{"type":"text","value":"Introduction"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/harlan-zw/unlighthouse","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Unlighthouse"}]},{"type":"text","value":" is an open-source package I built to scan your entire site using Google Lighthouse."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Building it was chaotic, with day-long bugs, constant refactoring and endless documentation reading."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Through building it, I learnt modern development practices, making use of the vast ecosystem of packages and tools."}]},{"type":"element","tag":"h2","props":{"id":"background-why-build-unlighthouse"},"children":[{"type":"text","value":"Background: Why build Unlighthouse?"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"As a freelancer I  keep on top of my clients organic growth with Google Search Console."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Was a day like any other, looking at one of my clients' dashboard. Seemingly out of nowhere, I saw the trend of page position, clicks and page views in free fall. My clients' income was based on organic traffic, not good."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"Trending down Google Search Console","height":"416","src":"/numbers-go-down","max-height":"242","width":"1552"},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Isolating the reason for the falling page rank wasn't easy. The site had issues, but what was causing the free fall? There was no easy way to know."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"To diagnose the issue, I used Google Lighthouse. I went through all pages of the site, noticing quite a number of issues. I spent a couple of days\nfixing them all up and improving the general performance of the site."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"What happened next? Things started turning around. I was able to invert the graph. Organic growth doubled in the next few months. Happy client."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"Trending up Google Search Console","height":"399","src":"/numbers-go-up","max-height":"242","width":"1554"},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Now that was out of the way, how could I make it easier to stay on top of the health of the sites I manage?"}]},{"type":"element","tag":"h2","props":{"id":"deciding-on-the-stack"},"children":[{"type":"text","value":"Deciding on the stack"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"I needed to build a tool that would run Google Lighthouse on an entire site with just the home page URL."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"I had a plan of attack for the build."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The backend would be build using Typescript and Node."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The frontend client would be built using Vue and Vite."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"But how would I be able to design this in a way that was easy to build and maintain?"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"I had seen the amazing work coming out of the "},{"type":"element","tag":"a","props":{"href":"https://github.com/unjs","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"UnJS"}]},{"type":"text","value":" ecosystem and knew that they could solve some of my problems."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"With that, the package would be known as "},{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"Un"}]},{"type":"text","value":" (inspired by Unjs) "},{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"Lighthouse"}]},{"type":"text","value":"."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Keeping a keen eye on other modern packages coming out, I took some of the best practices and tools I saw implemented."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The stack was split into three core parts:"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Monorepo: containing the dependencies to build, test and deploy the code"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Frontend: displaying searchable, filtering and sortable results"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Backend: generating the frontend, running the scans and providing an API for the frontend"}]}]},{"type":"element","tag":"h2","props":{"id":"monorepo"},"children":[{"type":"text","value":"Monorepo"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Implementing a monorepo is a keystone for a large project which will ship multiple packages. It allows you to\ngroup up logic, dependencies and documentation into a single repository."}]},{"type":"element","tag":"h3","props":{"id":"pnpm"},"children":[{"type":"text","value":"PNPM"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://pnpm.io/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"PNPM"}]},{"type":"text","value":" is the new kid on the block of node package managers and has gained a large following quickly, for good reason. It is the most performant package manager and has first class support for monorepos."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"There are many benefits to using a monorepo for a package. My personal favourite is it allows me to easily isolate logic and dependencies for your package, letting you write simpler code. Allowing end users to pull any specific part of your package that they want to use."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"Unlighthouse monorepo","height":"507","src":"/pnpm-monorepo","max-height":"400","width":"942"},"children":[]}]},{"type":"element","tag":"h3","props":{"id":"vitest"},"children":[{"type":"text","value":"Vitest"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://vitest.dev/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Vitest"}]},{"type":"text","value":" is also the new kid on the block of testing. It's original aim was to be a testing framework specifically for Vite, but it has ended up being a possible replacement for Jest entirely."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Vitest makes writing your logic and tests a breeze and I'd recommend checking it out for any project."}]},{"type":"element","tag":"h3","props":{"id":"unbuild"},"children":[{"type":"text","value":"Unbuild"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","height":"350","src":"https://opengraph.githubassets.com/a12c58f21ffef9686653c51d0203ab07a995d7450d3d690a1c8bd51e975df35c/unjs/unbuild"},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"This package is described as a \"A unified javascript build system\"."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"In reality, it's a minimal config way to build your package code to ESM and CJS."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"One of the amazing features of unbuild is stubbing. This allows you can run source code from your dist folder, meaning it transpiles just-in-time."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"This allows you to completely cut out the build step when you're iterating and testing integrations on your package."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"It's as simple as "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"unbuild --stub"}]},{"type":"text","value":"."}]},{"type":"element","tag":"code","props":{"code":"import { defineBuildConfig } from 'unbuild'\n\nexport default defineBuildConfig({\n  entries: [\n    { input: 'src/index' },\n    { input: 'src/process', outDir: 'dist/process', builder: 'mkdist', declaration: false },\n  ],\n})\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import { defineBuildConfig } from 'unbuild'\n\nexport default defineBuildConfig({\n  entries: [\n    { input: 'src/index' },\n    { input: 'src/process', outDir: 'dist/process', builder: 'mkdist', declaration: false },\n  ],\n})\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/unjs/unbuild","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"GitHub Repo Link"}]}]},{"type":"element","tag":"h2","props":{"id":"server"},"children":[{"type":"text","value":"Server"}]},{"type":"element","tag":"h3","props":{"id":"lighthouse-binary"},"children":[{"type":"text","value":"Lighthouse Binary"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Unlighthouse wouldn't be possible if Google hadn't published Lighthouse as its own "},{"type":"element","tag":"a","props":{"href":"https://github.com/GoogleChrome/lighthouse","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"NPM binary"}]},{"type":"text","value":"."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"To make Unlighthouse fast, I combined the binary with the package "},{"type":"element","tag":"a","props":{"href":"https://github.com/thomasdondorf/puppeteer-cluster","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"puppeteer-cluster"}]},{"type":"text","value":", which allows for multi-threaded lighthouse scans."}]},{"type":"element","tag":"h3","props":{"id":"unctx"},"children":[{"type":"text","value":"Unctx"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","height":"350","src":"https://opengraph.githubassets.com/16b7d5bc9f0ddbbbc59c5f8fd24c1f1f311d2ab6bb835be58fb0698631d4b624/unjs/unctx"},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"It's amazing that a simple pattern like composition has evaded Node packages for so long."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"With the introduction of Vue 3, composition became cool. And with that, unctx is composition for your own package."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"unctx allows you to define a scope where there's only a single instance of something that is globally accessible. This is incredibly useful for building packages, as you no longer need to be juggling core state. You can build your logic out as composables that interact with the core."}]},{"type":"element","tag":"code","props":{"code":"import { createContext } from 'unctx'\n\nconst engineContext = createContext<UnlighthouseContext>()\n\nexport const useUnlighthouse = engineContext.use as () => UnlighthouseContext\n\nexport const createUnlighthouse = async (userConfig: UserConfig, provider?: Provider) => {\n  // ...\n  engineContext.set(ctx, true)\n}\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import { createContext } from 'unctx'\n\nconst engineContext = createContext<UnlighthouseContext>()\n\nexport const useUnlighthouse = engineContext.use as () => UnlighthouseContext\n\nexport const createUnlighthouse = async (userConfig: UserConfig, provider?: Provider) => {\n  // ...\n  engineContext.set(ctx, true)\n}\n"}]}]}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/unjs/unctx","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"unctx GitHub Repo"}]}]}]},{"type":"element","tag":"h3","props":{"id":"hookable"},"children":[{"type":"text","value":"Hookable"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","height":"350","src":"https://opengraph.githubassets.com/6fd14beca1b9a811c7b46e4e61ec4ef8870a3f1407e21d47724b38cb6128e0b3/unjs/hookable"},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"For Nuxt.js users, you might be familiar with the concept of frameworks hooks. A way for you to modify or do something with the internal logic of Nuxt."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Building a package, I knew that this was a useful feature, not just for end-users, but for me as a way to organise logic."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Having a core which is hookable means you can avoid baking logic in that may be better suited elsewhere."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"For example, I wanted to make sure that Unlighthouse didn't start for integrations until they visited the page."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"I simply set a hook for it to start only when they visit the client."}]},{"type":"element","tag":"code","props":{"code":"hooks.hookOnce('visited-client', () => {\n  ctx.start()\n})\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"hooks.hookOnce('visited-client', () => {\n  ctx.start()\n})\n"}]}]}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/unjs/hookable","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Hookable GitHub Repo"}]}]}]},{"type":"element","tag":"h3","props":{"id":"unconfig"},"children":[{"type":"text","value":"Unconfig"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","height":"350","src":"https://opengraph.githubassets.com/f8bdfdebc7f32dd928adc557ea624fe7e4e4003400e90b3c41b414d818432b21/antfu/unconfig"},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Unconfig is a universal solution for loading configurations. This let me allow the package to load in a configuration from "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"unlighthouse.config.ts"}]},{"type":"text","value":" or a custom path, with barely any code."}]},{"type":"element","tag":"code","props":{"code":"import { loadConfig } from 'unconfig'\n\nconst configDefinition = await loadConfig<UserConfig>({\n  cwd: userConfig.root,\n  sources: [\n    {\n      files: [\n        'unlighthouse.config',\n        // may provide the config file as an argument\n        ...(userConfig.configFile ? [userConfig.configFile] : []),\n      ],\n      // default extensions\n      extensions: ['ts', 'js'],\n    },\n  ],\n})\nif (configDefinition.sources?.[0]) {\n  configFile = configDefinition.sources[0]\n  userConfig = defu(configDefinition.config, userConfig)\n}\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import { loadConfig } from 'unconfig'\n\nconst configDefinition = await loadConfig<UserConfig>({\n  cwd: userConfig.root,\n  sources: [\n    {\n      files: [\n        'unlighthouse.config',\n        // may provide the config file as an argument\n        ...(userConfig.configFile ? [userConfig.configFile] : []),\n      ],\n      // default extensions\n      extensions: ['ts', 'js'],\n    },\n  ],\n})\nif (configDefinition.sources?.[0]) {\n  configFile = configDefinition.sources[0]\n  userConfig = defu(configDefinition.config, userConfig)\n}\n"}]}]}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/antfu/unconfig","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Unconfig GitHub Repo"}]}]}]},{"type":"element","tag":"h3","props":{"id":"ufo"},"children":[{"type":"text","value":"ufo"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","height":"350","src":"https://repository-images.githubusercontent.com/318601574/674ca800-3a4a-11eb-901f-31ab7e452816"},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Dealing with URLs in Node isn't nice. For Unlighthouse I needed to deal with many URLS, I needed to make sure they were standardised no matter how they were formed."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"This meant using the ufo package heavily. The slash trimming came in handy and the origin detection."}]},{"type":"element","tag":"code","props":{"code":"export const trimSlashes = (s: string) => withoutLeadingSlash(withoutTrailingSlash(s))\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"export const trimSlashes = (s: string) => withoutLeadingSlash(withoutTrailingSlash(s))\n"}]}]}]},{"type":"element","tag":"code","props":{"code":"const site = new $URL(url).origin\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"const site = new $URL(url).origin\n"}]}]}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/unjs/ufo","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"ufo GitHub Repo"}]}]}]},{"type":"element","tag":"h3","props":{"id":"unrouted"},"children":[{"type":"text","value":"Unrouted"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","height":"350","src":"https://repository-images.githubusercontent.com/432034546/262d14fd-f00c-46b9-8b72-423a07dca06f"},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"I needed an API for the client to communicate with the Node server to fetch the status of the scan and submit re-scans."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The current JS offerings were a bit lackluster. I wanted something that just worked and had a nice way to use it."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"I ended up building unrouted as a way to solve that."}]},{"type":"element","tag":"code","props":{"code":"group('/api', () => {\n  group('/reports', () => {\n    post('/rescan', () => {\n      // ...\n      return true\n    })\n\n    post('/:id/rescan', () => {\n      const report = useReport()\n      const { worker } = useUnlighthouse()\n\n      if (report)\n        worker.requeueReport(report)\n    })\n  })\n\n  get('__launch', () => {\n    const { file } = useQuery<{ file: string }>()\n    if (!file) {\n      setStatusCode(400)\n      return false\n    }\n    const path = file.replace(resolvedConfig.root, '')\n    const resolved = join(resolvedConfig.root, path)\n    logger.info(`Launching file in editor: \\`${path}\\``)\n    launch(resolved)\n  })\n\n  get('ws', req => ws.serve(req))\n\n  get('reports', () => {\n    const { worker } = useUnlighthouse()\n\n    return worker.reports().filter(r => r.tasks.inspectHtmlTask === 'completed')\n  })\n\n  get('scan-meta', () => createScanMeta())\n})\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"group('/api', () => {\n  group('/reports', () => {\n    post('/rescan', () => {\n      // ...\n      return true\n    })\n\n    post('/:id/rescan', () => {\n      const report = useReport()\n      const { worker } = useUnlighthouse()\n\n      if (report)\n        worker.requeueReport(report)\n    })\n  })\n\n  get('__launch', () => {\n    const { file } = useQuery<{ file: string }>()\n    if (!file) {\n      setStatusCode(400)\n      return false\n    }\n    const path = file.replace(resolvedConfig.root, '')\n    const resolved = join(resolvedConfig.root, path)\n    logger.info(`Launching file in editor: \\`${path}\\``)\n    launch(resolved)\n  })\n\n  get('ws', req => ws.serve(req))\n\n  get('reports', () => {\n    const { worker } = useUnlighthouse()\n\n    return worker.reports().filter(r => r.tasks.inspectHtmlTask === 'completed')\n  })\n\n  get('scan-meta', () => createScanMeta())\n})\n"}]}]}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/harlan-zw/unrouted","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Unrouted GitHub Repo"}]}]}]},{"type":"element","tag":"h2","props":{"id":"client"},"children":[{"type":"text","value":"Client"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The code that what went into building the package."}]},{"type":"element","tag":"h3","props":{"id":"vue-3--vite-client"},"children":[{"type":"text","value":"Vue 3 / Vite client"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The beloved "},{"type":"element","tag":"a","props":{"href":"https://github.com/vitejs/vite","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Vite"}]},{"type":"text","value":" was to be used to make the development of the client as easy and fast as possible."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Vue v3 used to make use of the vast collection of utilities available at "},{"type":"element","tag":"a","props":{"href":"https://vueuse.org/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"VueUse"}]},{"type":"text","value":"."}]},{"type":"element","tag":"h2","props":{"id":"putting-it-together---part-2"},"children":[{"type":"text","value":"Putting It Together - Part 2"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Part 2 of this article will be coming soon where I go over some technical feats in putting together the above packages."}]},{"type":"element","tag":"h2","props":{"id":"conclusion"},"children":[{"type":"text","value":"Conclusion"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Thanks for reading Part 1. I hope you at least found it interesting or some of the links useful."}]}]},"publishedAt":"2022-07-31","image":"https://next.unlighthouse.dev/og.png","tags":["vue","vite","typescript"],"body":{"type":"root","children":[{"type":"element","tag":"toc","props":{},"children":[]},{"type":"element","tag":"primary","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"This article is a work in progress. Feel free to read it, but some sections are incomplete."}]}]},{"type":"element","tag":"h2","props":{"id":"introduction"},"children":[{"type":"text","value":"Introduction"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/harlan-zw/unlighthouse","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Unlighthouse"}]},{"type":"text","value":" is an open-source package I built to scan your entire site using Google Lighthouse."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Building it was chaotic, with day-long bugs, constant refactoring and endless documentation reading."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Through building it, I learnt modern development practices, making use of the vast ecosystem of packages and tools."}]},{"type":"element","tag":"h2","props":{"id":"background-why-build-unlighthouse"},"children":[{"type":"text","value":"Background: Why build Unlighthouse?"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"As a freelancer I  keep on top of my clients organic growth with Google Search Console."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Was a day like any other, looking at one of my clients' dashboard. Seemingly out of nowhere, I saw the trend of page position, clicks and page views in free fall. My clients' income was based on organic traffic, not good."}]},{"type":"element","tag":"Image","props":{"alt":"Trending down Google Search Console","height":241,"src":"/numbers-go-down","max-height":242,"width":900,"sizes":"md:900px sm:95vw xs:95vw"},"children":[]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Isolating the reason for the falling page rank wasn't easy. The site had issues, but what was causing the free fall? There was no easy way to know."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"To diagnose the issue, I used Google Lighthouse. I went through all pages of the site, noticing quite a number of issues. I spent a couple of days\nfixing them all up and improving the general performance of the site."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"What happened next? Things started turning around. I was able to invert the graph. Organic growth doubled in the next few months. Happy client."}]},{"type":"element","tag":"Image","props":{"alt":"Trending up Google Search Console","height":231,"src":"/numbers-go-up","max-height":242,"width":900,"sizes":"md:900px sm:95vw xs:95vw"},"children":[]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Now that was out of the way, how could I make it easier to stay on top of the health of the sites I manage?"}]},{"type":"element","tag":"h2","props":{"id":"deciding-on-the-stack"},"children":[{"type":"text","value":"Deciding on the stack"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"I needed to build a tool that would run Google Lighthouse on an entire site with just the home page URL."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"I had a plan of attack for the build."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The backend would be build using Typescript and Node."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The frontend client would be built using Vue and Vite."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"But how would I be able to design this in a way that was easy to build and maintain?"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"I had seen the amazing work coming out of the "},{"type":"element","tag":"a","props":{"href":"https://github.com/unjs","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"UnJS"}]},{"type":"text","value":" ecosystem and knew that they could solve some of my problems."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"With that, the package would be known as "},{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"Un"}]},{"type":"text","value":" (inspired by Unjs) "},{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"Lighthouse"}]},{"type":"text","value":"."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Keeping a keen eye on other modern packages coming out, I took some of the best practices and tools I saw implemented."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The stack was split into three core parts:"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Monorepo: containing the dependencies to build, test and deploy the code"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Frontend: displaying searchable, filtering and sortable results"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Backend: generating the frontend, running the scans and providing an API for the frontend"}]}]},{"type":"element","tag":"h2","props":{"id":"monorepo"},"children":[{"type":"text","value":"Monorepo"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Implementing a monorepo is a keystone for a large project which will ship multiple packages. It allows you to\ngroup up logic, dependencies and documentation into a single repository."}]},{"type":"element","tag":"h3","props":{"id":"pnpm"},"children":[{"type":"text","value":"PNPM"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://pnpm.io/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"PNPM"}]},{"type":"text","value":" is the new kid on the block of node package managers and has gained a large following quickly, for good reason. It is the most performant package manager and has first class support for monorepos."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"There are many benefits to using a monorepo for a package. My personal favourite is it allows me to easily isolate logic and dependencies for your package, letting you write simpler code. Allowing end users to pull any specific part of your package that they want to use."}]},{"type":"element","tag":"Image","props":{"alt":"Unlighthouse monorepo","height":400,"src":"/pnpm-monorepo","max-height":400,"width":743,"sizes":"md:743px sm:95vw xs:95vw"},"children":[]},{"type":"element","tag":"h3","props":{"id":"vitest"},"children":[{"type":"text","value":"Vitest"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://vitest.dev/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Vitest"}]},{"type":"text","value":" is also the new kid on the block of testing. It's original aim was to be a testing framework specifically for Vite, but it has ended up being a possible replacement for Jest entirely."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Vitest makes writing your logic and tests a breeze and I'd recommend checking it out for any project."}]},{"type":"element","tag":"h3","props":{"id":"unbuild"},"children":[{"type":"text","value":"Unbuild"}]},{"type":"element","tag":"Image","props":{"alt":"","height":350,"src":"https://opengraph.githubassets.com/a12c58f21ffef9686653c51d0203ab07a995d7450d3d690a1c8bd51e975df35c/unjs/unbuild"},"children":[]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"This package is described as a \"A unified javascript build system\"."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"In reality, it's a minimal config way to build your package code to ESM and CJS."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"One of the amazing features of unbuild is stubbing. This allows you can run source code from your dist folder, meaning it transpiles just-in-time."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"This allows you to completely cut out the build step when you're iterating and testing integrations on your package."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"It's as simple as "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"unbuild --stub"}]},{"type":"text","value":"."}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"ts","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"import { defineBuildConfig } from 'unbuild'\n\nexport default defineBuildConfig({\n  entries: [\n    { input: 'src/index' },\n    { input: 'src/process', outDir: 'dist/process', builder: 'mkdist', declaration: false },\n  ],\n})\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"defineBuildConfig"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"unbuild"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"defineBuildConfig"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"entries"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ["}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"input"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"src/index"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"input"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"src/process"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"outDir"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"dist/process"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"builder"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"mkdist"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"declaration"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"false"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  ]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/unjs/unbuild","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"GitHub Repo Link"}]}]},{"type":"element","tag":"h2","props":{"id":"server"},"children":[{"type":"text","value":"Server"}]},{"type":"element","tag":"h3","props":{"id":"lighthouse-binary"},"children":[{"type":"text","value":"Lighthouse Binary"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Unlighthouse wouldn't be possible if Google hadn't published Lighthouse as its own "},{"type":"element","tag":"a","props":{"href":"https://github.com/GoogleChrome/lighthouse","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"NPM binary"}]},{"type":"text","value":"."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"To make Unlighthouse fast, I combined the binary with the package "},{"type":"element","tag":"a","props":{"href":"https://github.com/thomasdondorf/puppeteer-cluster","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"puppeteer-cluster"}]},{"type":"text","value":", which allows for multi-threaded lighthouse scans."}]},{"type":"element","tag":"h3","props":{"id":"unctx"},"children":[{"type":"text","value":"Unctx"}]},{"type":"element","tag":"Image","props":{"alt":"","height":350,"src":"https://opengraph.githubassets.com/16b7d5bc9f0ddbbbc59c5f8fd24c1f1f311d2ab6bb835be58fb0698631d4b624/unjs/unctx"},"children":[]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"It's amazing that a simple pattern like composition has evaded Node packages for so long."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"With the introduction of Vue 3, composition became cool. And with that, unctx is composition for your own package."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"unctx allows you to define a scope where there's only a single instance of something that is globally accessible. This is incredibly useful for building packages, as you no longer need to be juggling core state. You can build your logic out as composables that interact with the core."}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"ts","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"import { createContext } from 'unctx'\n\nconst engineContext = createContext<UnlighthouseContext>()\n\nexport const useUnlighthouse = engineContext.use as () => UnlighthouseContext\n\nexport const createUnlighthouse = async (userConfig: UserConfig, provider?: Provider) => {\n  // ...\n  engineContext.set(ctx, true)\n}\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"createContext"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"unctx"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" engineContext "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"createContext"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"UnlighthouseContext"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"()"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" useUnlighthouse "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" engineContext"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"use "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"as"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"UnlighthouseContext"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" createUnlighthouse "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"async"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"userConfig"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"UserConfig"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" provider"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"?:"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Provider"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// ..."}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"engineContext"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"set"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"ctx"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"true"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/unjs/unctx","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"unctx GitHub Repo"}]}]}]},{"type":"element","tag":"h3","props":{"id":"hookable"},"children":[{"type":"text","value":"Hookable"}]},{"type":"element","tag":"Image","props":{"alt":"","height":350,"src":"https://opengraph.githubassets.com/6fd14beca1b9a811c7b46e4e61ec4ef8870a3f1407e21d47724b38cb6128e0b3/unjs/hookable"},"children":[]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"For Nuxt.js users, you might be familiar with the concept of frameworks hooks. A way for you to modify or do something with the internal logic of Nuxt."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Building a package, I knew that this was a useful feature, not just for end-users, but for me as a way to organise logic."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Having a core which is hookable means you can avoid baking logic in that may be better suited elsewhere."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"For example, I wanted to make sure that Unlighthouse didn't start for integrations until they visited the page."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"I simply set a hook for it to start only when they visit the client."}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"ts","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"hooks.hookOnce('visited-client', () => {\n  ctx.start()\n})\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"hooks"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"hookOnce"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"visited-client"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"ctx"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"start"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"()"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]}]}]}]}]}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/unjs/hookable","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Hookable GitHub Repo"}]}]}]},{"type":"element","tag":"h3","props":{"id":"unconfig"},"children":[{"type":"text","value":"Unconfig"}]},{"type":"element","tag":"Image","props":{"alt":"","height":350,"src":"https://opengraph.githubassets.com/f8bdfdebc7f32dd928adc557ea624fe7e4e4003400e90b3c41b414d818432b21/antfu/unconfig"},"children":[]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Unconfig is a universal solution for loading configurations. This let me allow the package to load in a configuration from "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"unlighthouse.config.ts"}]},{"type":"text","value":" or a custom path, with barely any code."}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"ts","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"import { loadConfig } from 'unconfig'\n\nconst configDefinition = await loadConfig<UserConfig>({\n  cwd: userConfig.root,\n  sources: [\n    {\n      files: [\n        'unlighthouse.config',\n        // may provide the config file as an argument\n        ...(userConfig.configFile ? [userConfig.configFile] : []),\n      ],\n      // default extensions\n      extensions: ['ts', 'js'],\n    },\n  ],\n})\nif (configDefinition.sources?.[0]) {\n  configFile = configDefinition.sources[0]\n  userConfig = defu(configDefinition.config, userConfig)\n}\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"loadConfig"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"unconfig"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" configDefinition "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"await"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"loadConfig"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"UserConfig"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"cwd"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" userConfig"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"root"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"sources"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ["}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"files"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ["}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"unlighthouse.config"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// may provide the config file as an argument"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"..."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"(userConfig"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"configFile "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"?"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" [userConfig"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"configFile] "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" [])"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"      ]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// default extensions"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"extensions"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ["}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"ts"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"js"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  ]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" (configDefinition"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"sources"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"?."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"["}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"0"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"]) "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"configFile"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"configDefinition"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"sources"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"["}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"0"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"]"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"userConfig"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"defu"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"configDefinition"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"config"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"userConfig"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/antfu/unconfig","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Unconfig GitHub Repo"}]}]}]},{"type":"element","tag":"h3","props":{"id":"ufo"},"children":[{"type":"text","value":"ufo"}]},{"type":"element","tag":"Image","props":{"alt":"","height":350,"src":"https://repository-images.githubusercontent.com/318601574/674ca800-3a4a-11eb-901f-31ab7e452816"},"children":[]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Dealing with URLs in Node isn't nice. For Unlighthouse I needed to deal with many URLS, I needed to make sure they were standardised no matter how they were formed."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"This meant using the ufo package heavily. The slash trimming came in handy and the origin detection."}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"ts","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"export const trimSlashes = (s: string) => withoutLeadingSlash(withoutTrailingSlash(s))\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" trimSlashes "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"s"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"string"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"withoutLeadingSlash"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"withoutTrailingSlash"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"(s))"}]}]}]}]}]}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"ts","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"const site = new $URL(url).origin\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" site "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"new"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"$URL"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"(url)"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"origin"}]}]}]}]}]}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/unjs/ufo","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"ufo GitHub Repo"}]}]}]},{"type":"element","tag":"h3","props":{"id":"unrouted"},"children":[{"type":"text","value":"Unrouted"}]},{"type":"element","tag":"Image","props":{"alt":"","height":350,"src":"https://repository-images.githubusercontent.com/432034546/262d14fd-f00c-46b9-8b72-423a07dca06f"},"children":[]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"I needed an API for the client to communicate with the Node server to fetch the status of the scan and submit re-scans."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The current JS offerings were a bit lackluster. I wanted something that just worked and had a nice way to use it."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"I ended up building unrouted as a way to solve that."}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"ts","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"group('/api', () => {\n  group('/reports', () => {\n    post('/rescan', () => {\n      // ...\n      return true\n    })\n\n    post('/:id/rescan', () => {\n      const report = useReport()\n      const { worker } = useUnlighthouse()\n\n      if (report)\n        worker.requeueReport(report)\n    })\n  })\n\n  get('__launch', () => {\n    const { file } = useQuery<{ file: string }>()\n    if (!file) {\n      setStatusCode(400)\n      return false\n    }\n    const path = file.replace(resolvedConfig.root, '')\n    const resolved = join(resolvedConfig.root, path)\n    logger.info(`Launching file in editor: \\`${path}\\``)\n    launch(resolved)\n  })\n\n  get('ws', req => ws.serve(req))\n\n  get('reports', () => {\n    const { worker } = useUnlighthouse()\n\n    return worker.reports().filter(r => r.tasks.inspectHtmlTask === 'completed')\n  })\n\n  get('scan-meta', () => createScanMeta())\n})\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"group"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/api"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"group"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/reports"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"post"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/rescan"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// ..."}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"true"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"post"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/:id/rescan"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"report"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"useReport"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"()"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"worker"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"useUnlighthouse"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"()"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"report"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"worker"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"requeueReport"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"report"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"get"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"__launch"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"file"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"useQuery"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" file"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"string"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"()"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"!"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"file"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":") "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"setStatusCode"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"400"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"false"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"file"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"replace"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"resolvedConfig"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"root"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"''"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"resolved"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"join"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"resolvedConfig"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"root"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"logger"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"info"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"`"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"Launching file in editor: "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\`"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"${"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\`"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"`"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"launch"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"resolved"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"get"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"ws"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"req"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"ws"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"serve"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"req"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"))"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"get"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"reports"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"worker"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"useUnlighthouse"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"()"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"worker"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"reports"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"filter"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"r"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"r"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"tasks"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"inspectHtmlTask"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"==="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"completed"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"get"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"scan-meta"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"createScanMeta"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"())"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]}]}]}]}]}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/harlan-zw/unrouted","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Unrouted GitHub Repo"}]}]}]},{"type":"element","tag":"h2","props":{"id":"client"},"children":[{"type":"text","value":"Client"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The code that what went into building the package."}]},{"type":"element","tag":"h3","props":{"id":"vue-3--vite-client"},"children":[{"type":"text","value":"Vue 3 / Vite client"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The beloved "},{"type":"element","tag":"a","props":{"href":"https://github.com/vitejs/vite","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Vite"}]},{"type":"text","value":" was to be used to make the development of the client as easy and fast as possible."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Vue v3 used to make use of the vast collection of utilities available at "},{"type":"element","tag":"a","props":{"href":"https://vueuse.org/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"VueUse"}]},{"type":"text","value":"."}]},{"type":"element","tag":"h2","props":{"id":"putting-it-together---part-2"},"children":[{"type":"text","value":"Putting It Together - Part 2"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Part 2 of this article will be coming soon where I go over some technical feats in putting together the above packages."}]},{"type":"element","tag":"h2","props":{"id":"conclusion"},"children":[{"type":"text","value":"Conclusion"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Thanks for reading Part 1. I hope you at least found it interesting or some of the links useful."}]}],"toc":{"title":"","searchDepth":2,"depth":2,"links":[{"id":"introduction","depth":2,"text":"Introduction"},{"id":"background-why-build-unlighthouse","depth":2,"text":"Background: Why build Unlighthouse?"},{"id":"deciding-on-the-stack","depth":2,"text":"Deciding on the stack"},{"id":"monorepo","depth":2,"text":"Monorepo","children":[{"id":"pnpm","depth":3,"text":"PNPM"},{"id":"vitest","depth":3,"text":"Vitest"},{"id":"unbuild","depth":3,"text":"Unbuild"}]},{"id":"server","depth":2,"text":"Server","children":[{"id":"lighthouse-binary","depth":3,"text":"Lighthouse Binary"},{"id":"unctx","depth":3,"text":"Unctx"},{"id":"hookable","depth":3,"text":"Hookable"},{"id":"unconfig","depth":3,"text":"Unconfig"},{"id":"ufo","depth":3,"text":"ufo"},{"id":"unrouted","depth":3,"text":"Unrouted"}]},{"id":"client","depth":2,"text":"Client","children":[{"id":"vue-3--vite-client","depth":3,"text":"Vue 3 / Vite client"}]},{"id":"putting-it-together---part-2","depth":2,"text":"Putting It Together - Part 2"},{"id":"conclusion","depth":2,"text":"Conclusion"}]}},"_type":"markdown","_id":"content:posts:modern-package-development.md","_source":"content","_file":"posts/modern-package-development.md","_extension":"md","storageMeta":{"atime":"2023-06-16T10:26:05.626Z","mtime":"2023-06-16T10:26:05.626Z","size":10765},"readingMins":6,"path":"/blog/modern-package-development","renderer":"post","schemaOrg":{"modifiedAt":"2023-06-16T10:26:05.626Z"},"modifiedAt":"2023-06-16T10:26:05.626Z"},{"_path":"/posts/vite-migration-plan","_draft":false,"_partial":false,"_empty":false,"title":"Vite迁移方案总结","description":"学习如何从 webpack 迁移至 vite","excerpt":{"type":"root","children":[{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"toc","props":{},"children":[]}]},{"type":"element","tag":"h2","props":{"id":"vite-概要介绍"},"children":[{"type":"text","value":"Vite 概要介绍"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"📚： "},{"type":"element","tag":"a","props":{"href":"https://vitejs.dev/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"官方文档"}]},{"type":"text","value":"，"},{"type":"element","tag":"a","props":{"href":"https://cn.vitejs.dev/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"中文文档"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"🔨： "},{"type":"element","tag":"a","props":{"href":""},"children":[{"type":"text","value":"常用设置文档"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"🧰： "},{"type":"element","tag":"a","props":{"href":""},"children":[{"type":"text","value":"API 文档"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"⛄：插件和其生态 - "},{"type":"element","tag":"a","props":{"href":"https://github.com/vitejs/awesome-vite##plugins","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"awesome-vite"}]}]}]},{"type":"element","tag":"h3","props":{"id":"什么是-vite"},"children":[{"type":"text","value":"什么是 Vite"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"在浏览器支持 ES 模块之前，JavaScript 并没有提供的原生机制让开发者以模块化的方式进行开发。"}]},{"type":"element","tag":"blockquote","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"这句话的意思其实就是浏览器以前不直接支持我们习惯写的 ES Moudle 语法，现在支持了，vite 充分利用了这一点。"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"之前针对这一问题，出现了各类的打包工具： "},{"type":"element","tag":"a","props":{"href":"https://webpack.js.org/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"webpack"}]},{"type":"text","value":"、"},{"type":"element","tag":"a","props":{"href":"https://rollupjs.org/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Rollup"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"a","props":{"href":"https://parceljs.org/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Parcel"}]},{"type":"text","value":" 等，这些工具说白了就是在干一件事 - 使用工具抓取、处理并将我们的源码模块串联成可以在浏览器中运行的文件。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"但是逐渐当我们的项目逐渐变得庞大起来，JS 文件变得很多很多，一个完整应用拥有的模块拥有几千个模块，这些构建工具的弊端就会展现出来。使用 JavaScript 开发的工具通常需要很长时间（甚至是几分钟！）才能启动开发服务器，即使使用 HMR，文件修改后的效果也需要几秒钟才能在浏览器中反映出来。如此循环往复，迟钝的反馈会极大地影响开发者的开发效率和幸福感。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"这些问题就成了 Vite 诞生的导火索。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"个人理解 Vite 的定义："}]},{"type":"element","tag":"blockquote","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Vite，一个基于浏览器原生 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"ES imports"}]},{"type":"text","value":" 的开发服务器。利用浏览器去解析 imports，在服务器端按需编译返回，完全跳过了打包这个概念，服务器随起随用。同时不仅有 Vue 文件支持，还搞定了热更新，而且热更新的速度不会随着模块增多而变慢。针对生产环境则可以把同一份代码用 rollup 打包。"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"使用 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vite"}]},{"type":"text","value":"  之后"}]},{"type":"element","tag":"code","props":{"code":"<div id=\"app\"></div>\n<script type=\"module\">\n  import { createApp } from \"vue\";\n  import Main from \"./Main.vue\";\n\n  createApp(Main).mount(\"##app\");\n</script>\n","language":"html"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"<div id=\"app\"></div>\n<script type=\"module\">\n  import { createApp } from \"vue\";\n  import Main from \"./Main.vue\";\n\n  createApp(Main).mount(\"##app\");\n</script>\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"preview","src":"https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/40d8c18b3052404182d62ae24803a663~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]}]},{"type":"element","tag":"h3","props":{"id":"vite-和-webpack-对比"},"children":[{"type":"text","value":"Vite 和 webpack 对比"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"webpack 和 Vite "},{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"构建模式"}]},{"type":"text","value":"截然不同，在浏览器没有支持模块化的时候，期望将所有源代码编译进一个 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"js"}]},{"type":"text","value":" 文件中，然后提供给浏览器使用。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"所以在开发中运行启动命令的时候，webpack 总是需要从入口文件索引到整个项目的文件，下一步可能会采用代码拆分编译成一个或者多个单独的 JS 文件，这一步需要一次生成所有路由下的编译后文件，伴随着服务启动的时间随着项目复杂度指数增加。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"","src":"https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/833fec894776472ab23db760ce891c3c~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"那么 Vite 是如何解决问题的呢？Vite 会在本地帮你启动一个服务器，当浏览器读取到整个 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"html"}]},{"type":"text","value":" 文件之后，会执行到 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" 的时候才去向服务端发送对应模块的请求，Vite 内部进行模板解析，代码编译等解析成浏览器可以执行的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"JS"}]},{"type":"text","value":" 文件返回到浏览器端，这里就是真正的按需加载，并且不会因为模块增多而变慢。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"img","src":"https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/09a8b06e9d8842498e60764e3ee7dcdc~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]}]},{"type":"element","tag":"h3","props":{"id":"vite-带来的收益是什么"},"children":[{"type":"text","value":"Vite 带来的收益是什么"}]},{"type":"element","tag":"ol","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"开发环境启服务器速度飞快"}]},{"type":"element","tag":"blockquote","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"构建工具为 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Webpack"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"服务器启动速度，启动时间随着模块数增多而变慢"}]}]},{"type":"element","tag":"br","props":{},"children":[]},{"type":"element","tag":"img","props":{"alt":"image-20210723152046683","src":"https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/7590ea884fd94087a310fa9aa3f87b24~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]},{"type":"element","tag":"br","props":{},"children":[]},{"type":"element","tag":"img","props":{"alt":"image-20210719184638199","src":"https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/5c8420a5817b4d098d2c7d8c5ed9a6b8~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]},{"type":"element","tag":"blockquote","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"构建工具为 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vite"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"服务器启动速度，相较于前者快了将近十几倍，而且测试项目的模块数目并不多，只有几个模块。如果是一个较大的工程项目，包含几百个几千个模块，"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vite"}]},{"type":"text","value":" 启动服务器的速度将会是 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"webpack"}]},{"type":"text","value":"的几千倍"}]}]},{"type":"element","tag":"br","props":{},"children":[]},{"type":"element","tag":"img","props":{"alt":"image-20210719184216175","src":"https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/a957a192a71748ea9a15acadab1d62a6~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"几乎实时的模块热更新"}]},{"type":"element","tag":"br","props":{},"children":[]},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"webpack"}]},{"type":"text","value":" 热更新也是需要重新编译一遍所有模块，然后启动服务器的，换句话来说 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"webpack"}]},{"type":"text","value":" 的热更新速度和初次编译启动时间相差不了多少，这样会给开发者带来一些负面的体验感，比如你在改动一个组件样式之后，可能需要等待很长一段时间页面才会重新渲染。"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vite"}]},{"type":"text","value":" 出现了，"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vite"}]},{"type":"text","value":"的热更新同样也运用到了 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"esbuild"}]},{"type":"text","value":" 的能力，可以准确的更新页面而无需重新加载页面或者删除应用程序状态。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"以上两点可以演示admin工程项目，和迁移admin工程项目对比速度"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"img","src":"https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/7c3bc07073f144359acbd53e7b09018e~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]}]},{"type":"element","tag":"blockquote","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"实现原理: static server + compile + HMR"}]},{"type":"element","tag":"ol","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"当前目录作为静态文件服务器根目录"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"拦截部分文件请求(处理 import node_modules模块，处理 .Vue等文件的编译)"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"websocket 实现 HMR"}]}]}]},{"type":"element","tag":"ol","props":{"start":3},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"所需文件按需编译，避免编译用不到的文件"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"开箱即用，便面各种 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Loader"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Plugin"}]},{"type":"text","value":" 的配置"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Typescript - 内置支持"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"less/sass/postcss - 内置支持"}]}]}]}]},{"type":"element","tag":"h2","props":{"id":"vite-基础应用"},"children":[{"type":"text","value":"Vite 基础应用"}]},{"type":"element","tag":"h3","props":{"id":"官方脚手架安装模板安装"},"children":[{"type":"text","value":"官方脚手架安装、模板安装"}]},{"type":"element","tag":"code","props":{"code":"## npm\nnpm init @vitejs/app\n\n## yarn\nyarn create @vitejs/app\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"## npm\nnpm init @vitejs/app\n\n## yarn\nyarn create @vitejs/app\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"你还可以通过附加的命令行选项直接指定项目名称和你想要使用的模板。例如，要构建一个 Vite + Vue 项目，运行:"}]},{"type":"element","tag":"code","props":{"code":"## npm 6.x\nnpm init @vitejs/app my-vue-app --template vue\n\n## npm 7+, 需要额外的双横线：\nnpm init @vitejs/app my-vue-app -- --template vue\n\n## yarn\nyarn create @vitejs/app my-vue-app --template vue\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"## npm 6.x\nnpm init @vitejs/app my-vue-app --template vue\n\n## npm 7+, 需要额外的双横线：\nnpm init @vitejs/app my-vue-app -- --template vue\n\n## yarn\nyarn create @vitejs/app my-vue-app --template vue\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"目前支持模板："}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vanilla"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vanilla-ts"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vue"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vue-ts"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"react"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"react-ts"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"preact"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"preact-ts"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"lit-element"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"lit-element-ts"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"svelte"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"svelte-ts"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Vue2+ts+vite 模板（暂时存在个人 github 上，且 tsc-decorator 分支还有bug）"}]},{"type":"element","tag":"code","props":{"code":"git clone https://github.com/251205668/vite-vue2-start\ncd vite-vue2-start\nyarn \nyarn dev\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"git clone https://github.com/251205668/vite-vue2-start\ncd vite-vue2-start\nyarn \nyarn dev\n"}]}]}]},{"type":"element","tag":"h3","props":{"id":"vite-中使用-typescript"},"children":[{"type":"text","value":"Vite 中使用 Typescript"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Vite 天然支持 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".ts"}]},{"type":"text","value":" 文件，Vite 使用 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"esbuild"}]},{"type":"text","value":" 转译 TS 的速度将会是 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"tsc"}]},{"type":"text","value":" 的 20~30 倍，同时 HMR 更新速度将会小于 50 ms。"}]},{"type":"element","tag":"blockquote","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"编写项目时需要将 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"tsconfig.json"}]},{"type":"text","value":" 的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"compilerOptions"}]},{"type":"text","value":" 设置 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"isolateModules: true"}]},{"type":"text","value":", 这样 TS 才会警告你哪些功能无法与独立编译模式一同工作。"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"esbuild简介"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"image-20210720160239282","src":"https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/4f97aa9980dc4edba478ce50a50b0851~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"为什么 esbuild 这么快，来自"},{"type":"element","tag":"a","props":{"href":"https://esbuild.github.io/faq/##why-is-esbuild-fast","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"官网解释"}]},{"type":"text","value":"，具体总结为以下几点："}]},{"type":"element","tag":"ol","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"使用 Go 编写，并且编译成了机器码"},{"type":"element","tag":"br","props":{},"children":[]},{"type":"text","value":"现在的构建工具一般都是用 JavaScript 进行编写的，对于这种解释型语言（动态语言）来说，在命令行下的性能非常糟糕。因为每次运行编译的时候 V8 引擎都是第一次遇见代码，无法进行任何优化措施。而 esbuild 使用 Go 这种编译型语言（静态语言）编写而成，已经编译成了机器可以直接执行的机器码。当 esbuild 在编译你的 javaScript 代码的时候，可能 Node 还在忙着解析你的构建工具的代码。"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"​       除此之外，Go 语言是为并发而设计的语言，而 JavaScript 明显不是（老单线程了）。"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Go 在线程之间共享使用内存空间，而 JS 想要在线程间传递数据还需要把数据序列化之后再传送。"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Go 和 JS 的并发都有相应的垃圾回收机制，Go 会在所有线程之间共享堆，对于 JS 而言，每一个线程都有一个独立的堆。"},{"type":"element","tag":"br","props":{},"children":[]},{"type":"text","value":"根据 esbuild 的作者的测试，这似乎将 JavaScript 的工作线程的并行处理能力减少了一半，可能是因为你的一半 CPU 核心忙于为另一半收集垃圾"}]}]},{"type":"element","tag":"ol","props":{"start":2},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"大量使用并行算法"},{"type":"element","tag":"br","props":{},"children":[]},{"type":"text","value":"除了 Go 语言天生对于并发的优势，使得其处理并发任务性能远远优于 JavaScript，\nEsbuild 的内部算法也是经过精心设计的，尽可能的压榨所有的 CPU 核心。"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"esbuild 的所有内容都是从零编写的"},{"type":"element","tag":"br","props":{},"children":[]},{"type":"text","value":"自己编写一切而不是使用第三方库有很多性能上的好处。可以从一开始就考虑到性能，可以确保所有的东西都使用一致的数据结构以避免昂贵的转换，当然，缺点就是这工作量非常大。"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"更有效利用内存"},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"esbuild 通过减少 AST 遍历次数（三次），来减小内存访问速度对于打包速度的影响"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Go 语言还有一个好处就是可以把数据更加紧凑的储存在内存中，从而使得高速 CPU 缓存可以存下更多的内容"}]}]}]}]},{"type":"element","tag":"h3","props":{"id":"vite-中使用-css"},"children":[{"type":"text","value":"Vite 中使用 CSS"}]},{"type":"element","tag":"ol","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"原生css 支持，这一点毋庸置疑"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/postcss/postcss/blob/main/docs/README-cn.md","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"postcss"}]},{"type":"text","value":" 支持"},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"变量定义"},{"type":"element","tag":"code","props":{"code":"/* postcss 命名空间式定义变量 */\n:root {\n  --main-font-color: blue;\n}\n\n.root {\n  /* 使用postcss 插件console，但是需要配置 */  \n  @console.error error;\n  color: var(--main-font-color);\n}\n","language":"css"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"/* postcss 命名空间式定义变量 */\n:root {\n  --main-font-color: blue;\n}\n\n.root {\n  /* 使用postcss 插件console，但是需要配置 */  \n  @console.error error;\n  color: var(--main-font-color);\n}\n"}]}]}]},{"type":"element","tag":"br","props":{},"children":[]},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"postcss.config.js"}]},{"type":"element","tag":"code","props":{"code":"module.exports = {\n  plugins: [require(\"@postcss-plugins/console\")],\n};\n","language":"javascript"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"module.exports = {\n  plugins: [require(\"@postcss-plugins/console\")],\n};\n"}]}]}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"@import"},{"type":"element","tag":"code","props":{"code":"@import url(\"./test.css\");\n\n/* postcss 命名空间式定义变量 */\n:root {\n  --main-font-color: blue;\n}\n\n.root {\n  @console.error error;\n  color: var(--main-font-color);\n}\n\n","language":"css"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"@import url(\"./test.css\");\n\n/* postcss 命名空间式定义变量 */\n:root {\n  --main-font-color: blue;\n}\n\n.root {\n  @console.error error;\n  color: var(--main-font-color);\n}\n\n"}]}]}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"等等新功能特性"}]}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"css预处理器支持"},{"type":"element","tag":"br","props":{},"children":[]},{"type":"text","value":"Vite 也同时提供了对 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".scss"}]},{"type":"text","value":", "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".sass"}]},{"type":"text","value":", "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".less"}]},{"type":"text","value":", "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".styl"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".stylus"}]},{"type":"text","value":" 文件的内置支持。没有必要为它们安装特定的 Vite 插件，但必须安装相应的预处理器依赖："},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"scss"},{"type":"element","tag":"code","props":{"code":"yarn add scss\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"yarn add scss\n"}]}]}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"less"},{"type":"element","tag":"code","props":{"code":"yarn add less\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"yarn add less\n"}]}]}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"stylus"},{"type":"element","tag":"code","props":{"code":"yarn add stylus\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"yarn add stylus\n"}]}]}]}]}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/css-modules/css-modules","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"css-modules"}]},{"type":"text","value":" 支持"},{"type":"element","tag":"br","props":{},"children":[]},{"type":"text","value":"通常一个大型项目的页面样式名都希望是按模块来划分的，并且保证唯一性，Vite 内置了 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"css-modules"}]},{"type":"text","value":" 的功能"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"​       使用方式:  创建对应 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"*.module.css"}]},{"type":"text","value":" 然后引入即可，下图为测试的案例"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"image-20210720173108971","src":"https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/e1da5116066e4a0ea1be10f534db926b~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]}]},{"type":"element","tag":"h3","props":{"id":"vite-集成-jsx-和-tsx"},"children":[{"type":"text","value":"Vite 集成 JSX 和 TSX"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".jsx"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".tsx"}]},{"type":"text","value":" 文件同样开箱即用。JSX 的转译同样是通过 "},{"type":"element","tag":"a","props":{"href":"https://esbuild.github.io/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"esbuild"}]},{"type":"text","value":"，Vue 3 用户配置 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"@vitejs/plugin-vue-jsx"}]},{"type":"text","value":" 即可"}]},{"type":"element","tag":"code","props":{"code":"import { defineConfig } from \"vite\";\nimport vue from \"@vitejs/plugin-vue\";\nimport vuejsx from \"@vitejs/plugin-vue-jsx\";\n\n// https://vitejs.dev/config/\nexport default defineConfig({\n  plugins: [vue(), vuejsx({})],\n});\n\n","language":"typescript"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import { defineConfig } from \"vite\";\nimport vue from \"@vitejs/plugin-vue\";\nimport vuejsx from \"@vitejs/plugin-vue-jsx\";\n\n// https://vitejs.dev/config/\nexport default defineConfig({\n  plugins: [vue(), vuejsx({})],\n});\n\n"}]}]}]},{"type":"element","tag":"blockquote","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Vue2 版本需要单独引入 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vite-plugin-vue2"}]},{"type":"text","value":" 来配合 vite 工具，并且暂时不支持 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"tsx + decorator"}]},{"type":"text","value":" 写法，详情可以见"}]},{"type":"element","tag":"code","props":{"code":"import { defineConfig } from \"vite\";\nimport { createVuePlugin } from \"vite-plugin-vue2\";\nimport ViteComponents from \"vite-plugin-components\";\nimport { resolve } from \"path\";\n\nconst config = defineConfig({\n  resolve: {\n    alias: {\n      \"@\": `${resolve(__dirname, \"src\")}`,\n    },\n  },\n  base: \"/vue-template/\",\n  build: {\n    minify: true,\n  },\n  plugins: [createVuePlugin({}), ViteComponents({ transformer: \"vue2\" })],\n  server: {\n    port: 8080,\n  },\n});\nexport default config;\n","language":"typescript"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import { defineConfig } from \"vite\";\nimport { createVuePlugin } from \"vite-plugin-vue2\";\nimport ViteComponents from \"vite-plugin-components\";\nimport { resolve } from \"path\";\n\nconst config = defineConfig({\n  resolve: {\n    alias: {\n      \"@\": `${resolve(__dirname, \"src\")}`,\n    },\n  },\n  base: \"/vue-template/\",\n  build: {\n    minify: true,\n  },\n  plugins: [createVuePlugin({}), ViteComponents({ transformer: \"vue2\" })],\n  server: {\n    port: 8080,\n  },\n});\nexport default config;\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Vue2.x版本 SFC + TS 写法基本一致"}]},{"type":"element","tag":"code","props":{"code":"<template>\n  <div class=\"home\">\n    <img alt=\"Vue logo\" src=\"../assets/logo.png\" />\n    <HelloWorld msg=\"Welcome to Your Vue.js + TypeScript App\" />\n  </div>\n</template>\n\n<script lang=\"ts\">\nimport { Component, Vue } from \"vue-property-decorator\";\n\n@Component\nexport default class Home extends Vue {\n  ...\n}\n</script>\n","language":"vue"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"<template>\n  <div class=\"home\">\n    <img alt=\"Vue logo\" src=\"../assets/logo.png\" />\n    <HelloWorld msg=\"Welcome to Your Vue.js + TypeScript App\" />\n  </div>\n</template>\n\n<script lang=\"ts\">\nimport { Component, Vue } from \"vue-property-decorator\";\n\n@Component\nexport default class Home extends Vue {\n  ...\n}\n</script>\n"}]}]}]}]},{"type":"element","tag":"h3","props":{"id":"viteconfigts-常用配置"},"children":[{"type":"text","value":"Vite.config.ts 常用配置"}]},{"type":"element","tag":"h4","props":{"id":"配置别名"},"children":[{"type":"text","value":"配置别名"}]},{"type":"element","tag":"code","props":{"code":"export default defineConfig({\n  resolve: {\n    alias: {\n      // 路径映射开头必须要加/\n      \"@\": \"/src\",\n      \"@styles\": \"/src/styles\",\n    },\n  },\n});\n","language":"typescript"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"export default defineConfig({\n  resolve: {\n    alias: {\n      // 路径映射开头必须要加/\n      \"@\": \"/src\",\n      \"@styles\": \"/src/styles\",\n    },\n  },\n});\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"配置语法提示"}]}]},{"type":"element","tag":"code","props":{"code":"{\n  \"compilerOptions\": {\n    \"baseUrl\": \"./\",\n    \"paths\": {\n      \"@/*\": [\"src/*\"],\n      \"@styles/*\": [\"src/styles/*\"]\n    }\n  },\n  \"include\": [\"src/**/*.ts\", \"src/**/*.d.ts\", \"src/**/*.tsx\", \"src/**/*.vue\"]\n}\n","language":"json"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"{\n  \"compilerOptions\": {\n    \"baseUrl\": \"./\",\n    \"paths\": {\n      \"@/*\": [\"src/*\"],\n      \"@styles/*\": [\"src/styles/*\"]\n    }\n  },\n  \"include\": [\"src/**/*.ts\", \"src/**/*.d.ts\", \"src/**/*.tsx\", \"src/**/*.vue\"]\n}\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"使用效果"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"image-20210720162535915","src":"https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/5372ce161b4f41b2ad3855486c0f1469~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]}]},{"type":"element","tag":"h4","props":{"id":"代理服务器"},"children":[{"type":"text","value":"代理服务器"}]},{"type":"element","tag":"code","props":{"code":"export default {\n  proxy: {\n    '/api': {\n      target: 'http://doman1.com',\n      changeOrigin: true,\n      rewrite: path => path.replace(/^\\/api/, '')\n    }\n  }\n}\n\n","language":"typescript"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"export default {\n  proxy: {\n    '/api': {\n      target: 'http://doman1.com',\n      changeOrigin: true,\n      rewrite: path => path.replace(/^\\/api/, '')\n    }\n  }\n}\n\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"具体使用"}]},{"type":"element","tag":"code","props":{"code":"fetch('/api/users').then(...)\n","language":"typescript"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"fetch('/api/users').then(...)\n"}]}]}]},{"type":"element","tag":"h4","props":{"id":"数据mock"},"children":[{"type":"text","value":"数据mock"}]},{"type":"element","tag":"h4","props":{"id":"当前模式和环境变量"},"children":[{"type":"text","value":"当前模式和环境变量"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Vite 上定义好的环境变量"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"import.meta.env.MODE"}]}]},{"type":"text","value":": {string} 应用运行的"},{"type":"element","tag":"a","props":{"href":"https://cn.vitejs.dev/guide/env-and-mode.html##modes","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"模式"}]},{"type":"text","value":"。"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"import.meta.env.BASE_URL"}]}]},{"type":"text","value":": {string} 部署应用时的基本 URL。他由"},{"type":"element","tag":"a","props":{"href":"https://cn.vitejs.dev/config/##base","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"base"}]},{"type":"text","value":" 配置项"}]},{"type":"text","value":"决定。"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"import.meta.env.PROD"}]}]},{"type":"text","value":": {boolean} 应用是否运行在生产环境。"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"import.meta.env.DEV"}]}]},{"type":"text","value":": {boolean} 应用是否运行在开发环境 (永远与 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"import.meta.env.PROD"}]},{"type":"text","value":"相反)"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"自定义环境变量"}]}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"开发环境(git 管理)"},{"type":"element","tag":"code","props":{"code":"// .env.development\nVITE_SOME_KEY=this is a development token\n","language":"env"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"// .env.development\nVITE_SOME_KEY=this is a development token\n"}]}]}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"生产环境(git 管理)"},{"type":"element","tag":"code","props":{"code":"// .env.production\nVITE_SOME_KEY=this is a production token\n","language":"env"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"// .env.production\nVITE_SOME_KEY=this is a production token\n"}]}]}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"本地开发环境"},{"type":"element","tag":"code","props":{"code":"// .env.development.local\nVITE_SOME_KEY=this is a development token but not managed by git\n","language":"env"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"// .env.development.local\nVITE_SOME_KEY=this is a development token but not managed by git\n"}]}]}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"本地生产环境"},{"type":"element","tag":"code","props":{"code":"// .env.production.local\nVITE_SOME_KEY=this is a production token but not managed by git\n","language":"env"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"// .env.production.local\nVITE_SOME_KEY=this is a production token but not managed by git\n"}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"案例"}]}]},{"type":"element","tag":"code","props":{"code":" return () => {\n      const mode = import.meta.env.MODE; // 模式\n      const baseUrl = import.meta.env.BASE_URL; //基本URL\n      const prod = import.meta.env.PROD; // 是否是生产环境\n      const dev = import.meta.env.DEV; // 是否是开发环境\n      const token = import.meta.env.VITE_SOME_KEY; // 自定义环境变量\n      return (\n        <div class=\"root\">\n          <p>当前模式：{mode}</p>\n          <p>当前baseURL：{baseUrl}</p>\n          <p>当前是否是生产环境：{prod}</p>\n          <p>当前是否是开发环境：{dev}</p>\n          <p>当前环境下token：{token}</p>\n        </div>\n      );\n    };\n","language":"typescript"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":" return () => {\n      const mode = import.meta.env.MODE; // 模式\n      const baseUrl = import.meta.env.BASE_URL; //基本URL\n      const prod = import.meta.env.PROD; // 是否是生产环境\n      const dev = import.meta.env.DEV; // 是否是开发环境\n      const token = import.meta.env.VITE_SOME_KEY; // 自定义环境变量\n      return (\n        <div class=\"root\">\n          <p>当前模式：{mode}</p>\n          <p>当前baseURL：{baseUrl}</p>\n          <p>当前是否是生产环境：{prod}</p>\n          <p>当前是否是开发环境：{dev}</p>\n          <p>当前环境下token：{token}</p>\n        </div>\n      );\n    };\n"}]}]}]},{"type":"element","tag":"h3","props":{"id":"其他选项"},"children":[{"type":"text","value":"其他选项"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"详情可以见 "},{"type":"element","tag":"a","props":{"href":"https://cn.vitejs.dev/config/##shared-options","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"官方文档配置"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"此处列出一个自己玩过的模板"}]},{"type":"element","tag":"code","props":{"code":"\n/**\n * https://vitejs.dev/config/\n * @type {import('vite').UserConfig}\n */\nexport default {\n    //项目根目录 \n    root: process.cwd(),\n    //项目部署的基础路径\n    base: \"/\",\n    //环境配置\n    mode: 'development',\n    //全局变量替换 Record<string, string>\n    define: {\n        \"\": \"\",\n        \"user\": \"users\",\n    },\n    //插件\n    plugins: [\n\n    ],\n    //静态资源服务的文件夹\n    publicDir: \"public\",\n\n    resolve: {\n        //别名\n        alias: {\n            \"@\": path.resolve(__dirname, \"/src\"),\n            \"comps\": path.resolve(__dirname, \"/src/components\")\n        },\n        dedupe: [],\n        //情景导出package.json配置中的exports 字段\n        conditions: [],\n        //解析package.json中的字段\n        mainFields: ['module', 'jsnext:main', 'jsnext'],\n        //导入时想要省略的扩展名列表\n        extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json']\n    },\n    css: {\n        //配置 CSS modules 的行为。选项将被传递给 postcss-modules。\n        modules: {\n\n        },\n        // PostCSS 配置（格式同 postcss.config.js）\n        // postcss-load-config 的插件配置\n        postcss: {\n\n        },\n        //指定传递给 CSS 预处理器的选项\n        preprocessorOptions: {\n            scss: {\n                additionalData: `$injectedColor: orange;`\n            }\n        }\n    },\n    json: {\n        //是否支持从 .json 文件中进行按名导入\n        namedExports: true,\n        //若设置为 true，导入的 JSON 会被转换为 export default JSON.parse(\"...\") 会比转译成对象字面量性能更好，\n        //尤其是当 JSON 文件较大的时候。\n        //开启此项，则会禁用按名导入\n        stringify: false\n    },\n    //继承自 esbuild 转换选项。最常见的用例是自定义 JSX\n    esbuild: {\n        jsxFactory: 'h',\n        jsxFragment: 'Fragment',\n        jsxInject: `import React from 'react'`\n    },\n    //静态资源处理  字符串|正则表达式\n    assetsInclude: '',\n    //调整控制台输出的级别 'info' | 'warn' | 'error' | 'silent'\n    logLevel: 'info',\n    //设为 false 可以避免 Vite 清屏而错过在终端中打印某些关键信息\n    clearScreen: true,\n    //服务\n    server: {\n        //服务器主机名\n        host: \"\",\n        //端口号\n        port: \"\",\n        //设为 true 时若端口已被占用则会直接退出，\n        //而不是尝试下一个可用端口\n        strictPort: true,\n        //https.createServer()配置项\n        https: \"\",\n        //服务器启动时自动在浏览器中打开应用程序。\n        //当此值为字符串时，会被用作 URL 的路径名\n        open: '/docs/index.html',\n        //自定义代理规则\n        proxy: {\n            // 字符串简写写法\n            '/foo': 'http://localhost:4567/foo',\n            // 选项写法\n            '/api': {\n                target: 'http://jsonplaceholder.typicode.com',\n                changeOrigin: true,\n                rewrite: (path) => path.replace(/^\\/api/, '')\n            },\n            // 正则表达式写法\n            '^/fallback/.*': {\n                target: 'http://jsonplaceholder.typicode.com',\n                changeOrigin: true,\n                rewrite: (path) => path.replace(/^\\/fallback/, '')\n            }\n        },\n        //开发服务器配置 CORS   \n        //boolean | CorsOptions\n        cors: {\n\n        },\n        //设置为 true 强制使依赖预构建\n        force: true,\n        //禁用或配置 HMR 连接\n        hmr: {\n\n        },\n        //传递给 chokidar 的文件系统监视器选项\n        watch: {\n\n        }\n    },\n    //构建\n    build: {\n        //浏览器兼容性  \"esnext\"|\"modules\"\n        target: \"modules\",\n        //输出路径\n        outDir: \"dist\",\n        //生成静态资源的存放路径\n        assetsDir: \"assets\",\n        //小于此阈值的导入或引用资源将内联为 base64 编码，以避免额外的 http 请求。设置为 0 可以完全禁用此项\n        assetsInlineLimit: 4096,\n        //启用/禁用 CSS 代码拆分\n        cssCodeSplit: true,\n        //构建后是否生成 source map 文件\n        sourcemap: false,\n        //自定义底层的 Rollup 打包配置\n        rollupOptions: {\n\n        },\n        //@rollup/plugin-commonjs 插件的选项\n        commonjsOptions: {\n\n        },\n        //构建的库\n        lib: {\n\n        },\n        //当设置为 true，构建后将会生成 manifest.json 文件\n        manifest: false,\n        //设置为 false 可以禁用最小化混淆，\n        //或是用来指定使用哪种混淆器\n        //boolean | 'terser' | 'esbuild'\n        minify: \"terser\",\n        //传递给 Terser 的更多 minify 选项。\n        terserOptions: {\n\n        },\n        //设置为 false 来禁用将构建后的文件写入磁盘\n        write: true,\n        //默认情况下，若 outDir 在 root 目录下，则 Vite 会在构建时清空该目录。\n        emptyOutDir: true,\n        //启用/禁用 brotli 压缩大小报告\n        brotliSize: true,\n        //chunk 大小警告的限制\n        chunkSizeWarningLimit: 500\n    },\n    //依赖优化选项\n    optimizeDeps: {\n        //检测需要预构建的依赖项\n        entries: [\n\n        ],\n        //预构建中强制排除的依赖项\n        exclude: [\n\n        ],\n        //默认情况下，不在 node_modules 中的，链接的包不会被预构建。使用此选项可强制预构建链接的包。\n        include: [\n\n        ]\n    },\n    //SSR 选项\n    ssr: {\n        //列出的是要为 SSR 强制外部化的依赖\n        external: [\n\n        ],\n        //列出的是防止被 SSR 外部化依赖项。\n        noExternal: [\n\n        ]\n    }\n}\n\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"\n/**\n * https://vitejs.dev/config/\n * @type {import('vite').UserConfig}\n */\nexport default {\n    //项目根目录 \n    root: process.cwd(),\n    //项目部署的基础路径\n    base: \"/\",\n    //环境配置\n    mode: 'development',\n    //全局变量替换 Record<string, string>\n    define: {\n        \"\": \"\",\n        \"user\": \"users\",\n    },\n    //插件\n    plugins: [\n\n    ],\n    //静态资源服务的文件夹\n    publicDir: \"public\",\n\n    resolve: {\n        //别名\n        alias: {\n            \"@\": path.resolve(__dirname, \"/src\"),\n            \"comps\": path.resolve(__dirname, \"/src/components\")\n        },\n        dedupe: [],\n        //情景导出package.json配置中的exports 字段\n        conditions: [],\n        //解析package.json中的字段\n        mainFields: ['module', 'jsnext:main', 'jsnext'],\n        //导入时想要省略的扩展名列表\n        extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json']\n    },\n    css: {\n        //配置 CSS modules 的行为。选项将被传递给 postcss-modules。\n        modules: {\n\n        },\n        // PostCSS 配置（格式同 postcss.config.js）\n        // postcss-load-config 的插件配置\n        postcss: {\n\n        },\n        //指定传递给 CSS 预处理器的选项\n        preprocessorOptions: {\n            scss: {\n                additionalData: `$injectedColor: orange;`\n            }\n        }\n    },\n    json: {\n        //是否支持从 .json 文件中进行按名导入\n        namedExports: true,\n        //若设置为 true，导入的 JSON 会被转换为 export default JSON.parse(\"...\") 会比转译成对象字面量性能更好，\n        //尤其是当 JSON 文件较大的时候。\n        //开启此项，则会禁用按名导入\n        stringify: false\n    },\n    //继承自 esbuild 转换选项。最常见的用例是自定义 JSX\n    esbuild: {\n        jsxFactory: 'h',\n        jsxFragment: 'Fragment',\n        jsxInject: `import React from 'react'`\n    },\n    //静态资源处理  字符串|正则表达式\n    assetsInclude: '',\n    //调整控制台输出的级别 'info' | 'warn' | 'error' | 'silent'\n    logLevel: 'info',\n    //设为 false 可以避免 Vite 清屏而错过在终端中打印某些关键信息\n    clearScreen: true,\n    //服务\n    server: {\n        //服务器主机名\n        host: \"\",\n        //端口号\n        port: \"\",\n        //设为 true 时若端口已被占用则会直接退出，\n        //而不是尝试下一个可用端口\n        strictPort: true,\n        //https.createServer()配置项\n        https: \"\",\n        //服务器启动时自动在浏览器中打开应用程序。\n        //当此值为字符串时，会被用作 URL 的路径名\n        open: '/docs/index.html',\n        //自定义代理规则\n        proxy: {\n            // 字符串简写写法\n            '/foo': 'http://localhost:4567/foo',\n            // 选项写法\n            '/api': {\n                target: 'http://jsonplaceholder.typicode.com',\n                changeOrigin: true,\n                rewrite: (path) => path.replace(/^\\/api/, '')\n            },\n            // 正则表达式写法\n            '^/fallback/.*': {\n                target: 'http://jsonplaceholder.typicode.com',\n                changeOrigin: true,\n                rewrite: (path) => path.replace(/^\\/fallback/, '')\n            }\n        },\n        //开发服务器配置 CORS   \n        //boolean | CorsOptions\n        cors: {\n\n        },\n        //设置为 true 强制使依赖预构建\n        force: true,\n        //禁用或配置 HMR 连接\n        hmr: {\n\n        },\n        //传递给 chokidar 的文件系统监视器选项\n        watch: {\n\n        }\n    },\n    //构建\n    build: {\n        //浏览器兼容性  \"esnext\"|\"modules\"\n        target: \"modules\",\n        //输出路径\n        outDir: \"dist\",\n        //生成静态资源的存放路径\n        assetsDir: \"assets\",\n        //小于此阈值的导入或引用资源将内联为 base64 编码，以避免额外的 http 请求。设置为 0 可以完全禁用此项\n        assetsInlineLimit: 4096,\n        //启用/禁用 CSS 代码拆分\n        cssCodeSplit: true,\n        //构建后是否生成 source map 文件\n        sourcemap: false,\n        //自定义底层的 Rollup 打包配置\n        rollupOptions: {\n\n        },\n        //@rollup/plugin-commonjs 插件的选项\n        commonjsOptions: {\n\n        },\n        //构建的库\n        lib: {\n\n        },\n        //当设置为 true，构建后将会生成 manifest.json 文件\n        manifest: false,\n        //设置为 false 可以禁用最小化混淆，\n        //或是用来指定使用哪种混淆器\n        //boolean | 'terser' | 'esbuild'\n        minify: \"terser\",\n        //传递给 Terser 的更多 minify 选项。\n        terserOptions: {\n\n        },\n        //设置为 false 来禁用将构建后的文件写入磁盘\n        write: true,\n        //默认情况下，若 outDir 在 root 目录下，则 Vite 会在构建时清空该目录。\n        emptyOutDir: true,\n        //启用/禁用 brotli 压缩大小报告\n        brotliSize: true,\n        //chunk 大小警告的限制\n        chunkSizeWarningLimit: 500\n    },\n    //依赖优化选项\n    optimizeDeps: {\n        //检测需要预构建的依赖项\n        entries: [\n\n        ],\n        //预构建中强制排除的依赖项\n        exclude: [\n\n        ],\n        //默认情况下，不在 node_modules 中的，链接的包不会被预构建。使用此选项可强制预构建链接的包。\n        include: [\n\n        ]\n    },\n    //SSR 选项\n    ssr: {\n        //列出的是要为 SSR 强制外部化的依赖\n        external: [\n\n        ],\n        //列出的是防止被 SSR 外部化依赖项。\n        noExternal: [\n\n        ]\n    }\n}\n\n"}]}]}]},{"type":"element","tag":"h3","props":{"id":"webpack-进军-vite"},"children":[{"type":"text","value":"webpack 进军 vite"}]},{"type":"element","tag":"h4","props":{"id":"如何迁移"},"children":[{"type":"text","value":"如何迁移"}]},{"type":"element","tag":"ol","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"首先需要入门 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vite"}]},{"type":"text","value":" 特性"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue2"}]},{"type":"text","value":" 版本迁移需要安装 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vite-plugin-vue2"}]},{"type":"text","value":" 插件，然后使用其暴露的 API  "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"createvuePlugin"}]},{"type":"text","value":" 让 Vite 能够正常编译运行。"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue3"}]},{"type":"text","value":" 版本就不列举~"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"删除一切 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vue-cli"}]},{"type":"text","value":" 插件和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"babel"}]},{"type":"text","value":" 插件，这里删除之后一定要注意检查哪一部分是否依赖于某个插件，如果插件依赖关系很强，针对这种场景 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vite"}]},{"type":"text","value":" 同样提供 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"rollup/babel"}]},{"type":"text","value":" 插件配置 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"babel"}]},{"type":"text","value":"。"},{"type":"element","tag":"blockquote","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Vue2.x 版本使用 babel 会有一个坑，因为依赖于 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vite-plugin-vue2"}]},{"type":"text","value":"，但是里面默认将读取 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".babelrc"}]},{"type":"text","value":" 配置关闭，这里需要手动改回来。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"image-20210721164134928","src":"https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/43eab40494a44694ba3fc755b11e7aee~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]}]}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"dependencies"}]},{"type":"text","value":" 不用动，因为这些不会影响正常编译"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"查看"},{"type":"element","tag":"a","props":{"href":"https://cn.vitejs.dev/config/##config-file","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"文档配置"}]},{"type":"text","value":"，逐步将 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vue.config.js"}]},{"type":"text","value":" 迁移至 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vite.config.ts"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"环境变量迁移参考上述文档，准备 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"src/index.html"}]},{"type":"text","value":"，只需要改动启动入口 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"type = module"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"修改 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"script"}]},{"type":"text","value":"，修改为和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vite"}]},{"type":"text","value":" 相关脚本"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"个性化构建：因为 vite 内置构建工具为 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"rollup"}]},{"type":"text","value":"，所以如果需要对大型项目构建进行优化，可能会需要学习 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"rollup"}]},{"type":"text","value":"，当然 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vite"}]},{"type":"text","value":" 也提供了和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"webpack"}]},{"type":"text","value":" 构建配置相似的 "},{"type":"element","tag":"a","props":{"href":"https://cn.vitejs.dev/config/##build-options","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"API"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"如需配置 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"SSR"}]},{"type":"text","value":"，这一部分"},{"type":"element","tag":"a","props":{"href":"https://cn.vitejs.dev/config/##ssr-options","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"文档"}]},{"type":"text","value":"也有解释，但是目前 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vite"}]},{"type":"text","value":" 对 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"SSR"}]},{"type":"text","value":" 的支持还在探索"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"使用 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"composition-api"}]},{"type":"text","value":" ? 可以安装插件 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"@vue/composition-api"}]},{"type":"text","value":"，然后再入口文件 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue.use(VueCompositionAPI"}]},{"type":"text","value":" 即可"}]}]},{"type":"element","tag":"h4","props":{"id":"迁移踩过的坑"},"children":[{"type":"text","value":"迁移踩过的坑"}]},{"type":"element","tag":"ol","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"vue2 + vite2 + tsx 压根不支持 decorator 写法"},{"type":"element","tag":"br","props":{},"children":[]},{"type":"element","tag":"img","props":{"alt":"image-20210721110601580","src":"https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/ebd849bf1eda4cfaa0f069c4184a9dfd~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"解决方案："}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"经过排查，原因已经确定，"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vite-plugin-vue2"}]},{"type":"text","value":" 的作者在设计初衷就希望编译走 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"esbuild"}]},{"type":"text","value":" 而不是走 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"babel"}]},{"type":"text","value":" ，所以他将入口文件读取"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".babelrc"}]},{"type":"text","value":" 默认关闭了，所以导致我怎么修改安装 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"babel"}]},{"type":"text","value":" 插件都无法生效。"}]},{"type":"element","tag":"blockquote","props":{},"children":[{"type":"element","tag":"ol","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"安装两个插件用于解析装饰器写法，并创建 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".babelrc"}]},{"type":"text","value":"加入以下配置"},{"type":"element","tag":"code","props":{"code":"yarn add @babel/plugin-proposal-decorators\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"yarn add @babel/plugin-proposal-decorators\n"}]}]}]},{"type":"element","tag":"code","props":{"code":"yarn add @babel/plugin-proposal-class-properties\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"yarn add @babel/plugin-proposal-class-properties\n"}]}]}]},{"type":"element","tag":"code","props":{"code":"{\n  \"assumptions\": {\n    \"setPublicClassFields\": true\n  },\n  \"plugins\": [\n    [\"@babel/plugin-proposal-decorators\", { \"legacy\": true }],\n    [\"@babel/plugin-proposal-class-properties\"]\n  ]\n}\n   \n"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"{\n  \"assumptions\": {\n    \"setPublicClassFields\": true\n  },\n  \"plugins\": [\n    [\"@babel/plugin-proposal-decorators\", { \"legacy\": true }],\n    [\"@babel/plugin-proposal-class-properties\"]\n  ]\n}\n   \n"}]}]}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"开启 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vite-plugin-vue2"}]},{"type":"text","value":" 读取 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".babelrc"}]},{"type":"text","value":" 选项"},{"type":"element","tag":"br","props":{},"children":[]},{"type":"element","tag":"img","props":{"alt":"image-20210721170737255","src":"https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/62468cf5139a487b91f82bc87141e6a8~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]}]}]}]},{"type":"element","tag":"ol","props":{"start":2},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Vite2 迁移需要将所有的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"CommonJS"}]},{"type":"text","value":" 替换成 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"ESM"}]},{"type":"text","value":" 写法，否则运行会报 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Uncaught ReferenceError: require is not defined"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Vite 应用的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"title"}]},{"type":"text","value":" 默认是写死的，如需要替换成实际的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"title"}]},{"type":"text","value":" 值需要安装 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vite-plugin-html"}]},{"type":"text","value":" 插件，然后通过 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"ejs"}]},{"type":"text","value":" 模板注入变量。"},{"type":"element","tag":"code","props":{"code":"// vite.config.ts\nimport { defineConfig } from 'vite';\nimport { createVuePlugin } from 'vite-plugin-vue2';\n+ import { injectHtml } from 'vite-plugin-html';\n\nexport default defineConfig({\n  plugins: [\n    createVuePlugin(),\n+   injectHtml({\n+     injectData: {\n+       title: '用户管理系统',\n+     },\n    }),\n  ],\n  server: {\n    proxy,\n  },\n});\n","language":"typescript"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"// vite.config.ts\nimport { defineConfig } from 'vite';\nimport { createVuePlugin } from 'vite-plugin-vue2';\n+ import { injectHtml } from 'vite-plugin-html';\n\nexport default defineConfig({\n  plugins: [\n    createVuePlugin(),\n+   injectHtml({\n+     injectData: {\n+       title: '用户管理系统',\n+     },\n    }),\n  ],\n  server: {\n    proxy,\n  },\n});\n"}]}]}]},{"type":"element","tag":"br","props":{},"children":[]},{"type":"text","value":"然后修改 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"index.html"}]},{"type":"element","tag":"code","props":{"code":"<!DOCTYPE html>\n<html lang=\"en\">\n\n<head>\n  <meta charset=\"utf-8\">\n  <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n  <meta name=\"viewport\" content=\"width=device-width,initial-scale=1.0\">\n- <title><%= htmlWebpackPlugin.options.title %></title>\n+ <title><%= title %></title>\n</head>\n\n<body>\n  <noscript>\n-   We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled.\n+   We're sorry but <%= title %> doesn't work properly without JavaScript enabled.\n  </noscript>\n  <div id=\"app\"></div>\n  <script type=\"module\" src=\"/src/main.ts\"></script>\n</body>\n\n</html>\n\n","language":"html"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"<!DOCTYPE html>\n<html lang=\"en\">\n\n<head>\n  <meta charset=\"utf-8\">\n  <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n  <meta name=\"viewport\" content=\"width=device-width,initial-scale=1.0\">\n- <title><%= htmlWebpackPlugin.options.title %></title>\n+ <title><%= title %></title>\n</head>\n\n<body>\n  <noscript>\n-   We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled.\n+   We're sorry but <%= title %> doesn't work properly without JavaScript enabled.\n  </noscript>\n  <div id=\"app\"></div>\n  <script type=\"module\" src=\"/src/main.ts\"></script>\n</body>\n\n</html>\n\n"}]}]}]}]}]},{"type":"element","tag":"h2","props":{"id":"vite-常用插件"},"children":[{"type":"text","value":"Vite 常用插件"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Vite 插件依赖于 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Rollup"}]},{"type":"text","value":" 编写，未来将需要学习 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Rollup"}]},{"type":"text","value":" 插件编写"}]},{"type":"element","tag":"h3","props":{"id":"vitejsplugin-vue"},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/vitejs/vite/tree/main/packages/plugin-vue","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"@vitejs/plugin-vue"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"提供 Vue3 单文件组件支持"}]},{"type":"element","tag":"h3","props":{"id":"vitejsplugin-vue-jsx"},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/vitejs/vite/tree/main/packages/plugin-vue-jsx","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"@vitejs/plugin-vue-jsx"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"提供 Vue3 JSX 支持"}]},{"type":"element","tag":"h3","props":{"id":"vitejsplugin-legacy"},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/vitejs/vite/tree/main/packages/plugin-legacy","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"@vitejs/plugin-legacy"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"为打包后的文件提供传统浏览器兼容性支持"}]},{"type":"element","tag":"h3","props":{"id":"vitejsvite-plugin-vue2"},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/underfin/vite-plugin-vue2","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"@vitejs/vite-plugin-vue2"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"提供 Vue2 单文件组件支持，内置 JSX"}]},{"type":"element","tag":"h3","props":{"id":"vite-plugin-components"},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/antfu/vite-plugin-components","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"@vite-plugin-components"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"提供 Vue 组件自动导入功能，无需导入单文件组件"}]},{"type":"element","tag":"h2","props":{"id":"配合-vue3x-搭建工程化项目"},"children":[{"type":"text","value":"配合 Vue3.x 搭建工程化项目"}]},{"type":"element","tag":"h3","props":{"id":"搭建基础工程"},"children":[{"type":"text","value":"搭建基础工程"}]},{"type":"element","tag":"code","props":{"code":"yarn create @vitejs/app\n##npm\nnpm init @vitejs/app\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"yarn create @vitejs/app\n##npm\nnpm init @vitejs/app\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"选择模板 vue-ts"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"image-20210722104103443","src":"https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/3606756e1e9246ff978688bc059a2320~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]}]},{"type":"element","tag":"h3","props":{"id":"简单修改-vite-配置"},"children":[{"type":"text","value":"简单修改 vite 配置"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"简单配置以下路径代理、端口和打包路径"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"修改 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vite.config.ts"}]}]},{"type":"element","tag":"code","props":{"code":"export default defineConfig({\n  plugins: [vue()],\n  base: \"./\",\n  resolve: {\n    alias: {\n      \"@\": \"/src\",\n    },\n  },\n   server: {\n    port: 8080,\n    cors: true,\n  },\n});\n","language":"typescript"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"export default defineConfig({\n  plugins: [vue()],\n  base: \"./\",\n  resolve: {\n    alias: {\n      \"@\": \"/src\",\n    },\n  },\n   server: {\n    port: 8080,\n    cors: true,\n  },\n});\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"路径代理之后附带修改一下 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"tsconfig.json"}]},{"type":"text","value":"，增加语法提示"}]},{"type":"element","tag":"code","props":{"code":" { \"compilerOptions\": {\n   ...\n    \"baseUrl\": \"./\",\n    \"paths\": {\n      \"@/*\": [\"src/*\"]\n    }\n  }\n }\n","language":"json"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":" { \"compilerOptions\": {\n   ...\n    \"baseUrl\": \"./\",\n    \"paths\": {\n      \"@/*\": [\"src/*\"]\n    }\n  }\n }\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"如需配置接口代理，添加对应的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"proxy"}]},{"type":"text","value":" 代理即可"}]},{"type":"element","tag":"h3","props":{"id":"整理目录结构"},"children":[{"type":"text","value":"整理目录结构"}]},{"type":"element","tag":"code","props":{"code":"├── .husky/                        // commit 前置hooks\n├── .vscode/                       // setting.json\n├── public/\n└── src/\n    ├── assets/                    // 静态资源及通用css目录\n    ├── common/                    // 通用组件目录\n    ├── constant/                  // 常量或枚举目录\n    ├── components/                // 业务组件目录\n    ├── router/                    // 路由配置目录\n    ├── store/                     // 状态管理目录\n    ├── utils/                     // 工具函数目录\n    ├── views/                     // 页面组件目录\n    ├── App.vue\n    ├── main.ts\n    ├── shims-vue.d.ts\n    ├── vite-env.d.ts\n├── tests/                         // 单元测试目录\n├── index.html\n├── tsconfig.json                  // TypeScript 配置文件\n├── .editorconfig                  // 编码风格 配置文件\n├── .eslintrc.js                   // Eslint 配置文件\n├── .eslintignore                  // Eslint 配置忽略文件\n├── .prettierrc.json                  // TypeScript 配置文件\n├── tsconfig.json                  // TypeScript 配置文件\n├── vite.config.ts                 // Vite 配置文件\n├── yarn.lock                \n└── package.json\n\n"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"├── .husky/                        // commit 前置hooks\n├── .vscode/                       // setting.json\n├── public/\n└── src/\n    ├── assets/                    // 静态资源及通用css目录\n    ├── common/                    // 通用组件目录\n    ├── constant/                  // 常量或枚举目录\n    ├── components/                // 业务组件目录\n    ├── router/                    // 路由配置目录\n    ├── store/                     // 状态管理目录\n    ├── utils/                     // 工具函数目录\n    ├── views/                     // 页面组件目录\n    ├── App.vue\n    ├── main.ts\n    ├── shims-vue.d.ts\n    ├── vite-env.d.ts\n├── tests/                         // 单元测试目录\n├── index.html\n├── tsconfig.json                  // TypeScript 配置文件\n├── .editorconfig                  // 编码风格 配置文件\n├── .eslintrc.js                   // Eslint 配置文件\n├── .eslintignore                  // Eslint 配置忽略文件\n├── .prettierrc.json                  // TypeScript 配置文件\n├── tsconfig.json                  // TypeScript 配置文件\n├── vite.config.ts                 // Vite 配置文件\n├── yarn.lock                \n└── package.json\n\n"}]}]}]},{"type":"element","tag":"h3","props":{"id":"整合部分工具"},"children":[{"type":"text","value":"整合部分工具"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"vue-router"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"安装支持 Vue3 的路由工具 vue-router@4"}]},{"type":"element","tag":"code","props":{"code":"yarn add vue-router@4\n","language":"bash"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"yarn add vue-router@4\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"创建 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"src/router/index.ts"}]},{"type":"text","value":" 文件"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"src"}]},{"type":"text","value":" 下创建 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"router"}]},{"type":"text","value":" 目录，然后在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"router"}]},{"type":"text","value":" 目录里新建 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"index.ts"}]},{"type":"text","value":" 文件："}]},{"type":"element","tag":"code","props":{"code":"import { createRouter, createWebHashHistory, RouteRecordRaw } from \"vue-router\";\nimport Home from \"@/views/Home.vue\";\nimport Pinia from \"@/views/pinia.vue\";\nimport VueRouter from \"@/views/vue-router.vue\";\nimport Axios from \"@/views/Axios.vue\";\nconst routes: Array<RouteRecordRaw> = [\n  {\n    path: \"/\",\n    name: \"Home\",\n    component: Home,\n  },\n  {\n    path: \"/pinia\",\n    name: \"Pinia\",\n    component: Pinia,\n  },\n  {\n    path: \"/vue-router\",\n    name: \"VueRouter\",\n    component: VueRouter,\n  },\n  {\n    path: \"/axios\",\n    name: \"axios\",\n    component: Axios,\n  },\n];\n\nconst router = createRouter({\n  history: createWebHashHistory(),\n  routes,\n});\n\nexport default router;\n","language":"typescript"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import { createRouter, createWebHashHistory, RouteRecordRaw } from \"vue-router\";\nimport Home from \"@/views/Home.vue\";\nimport Pinia from \"@/views/pinia.vue\";\nimport VueRouter from \"@/views/vue-router.vue\";\nimport Axios from \"@/views/Axios.vue\";\nconst routes: Array<RouteRecordRaw> = [\n  {\n    path: \"/\",\n    name: \"Home\",\n    component: Home,\n  },\n  {\n    path: \"/pinia\",\n    name: \"Pinia\",\n    component: Pinia,\n  },\n  {\n    path: \"/vue-router\",\n    name: \"VueRouter\",\n    component: VueRouter,\n  },\n  {\n    path: \"/axios\",\n    name: \"axios\",\n    component: Axios,\n  },\n];\n\nconst router = createRouter({\n  history: createWebHashHistory(),\n  routes,\n});\n\nexport default router;\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"根据本项目路由配置的实际情况，你需要在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"src"}]},{"type":"text","value":" 下创建 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"views"}]},{"type":"text","value":" 目录，用来存储页面组件。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"main.ts"}]},{"type":"text","value":" 文件中挂载路由配置"}]},{"type":"element","tag":"code","props":{"code":"import { createApp } from 'vue'\nimport App from './App.vue'\nimport router from './router/index'\n\ncreateApp(App).use(router).mount('##app')\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import { createApp } from 'vue'\nimport App from './App.vue'\nimport router from './router/index'\n\ncreateApp(App).use(router).mount('##app')\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"Pinia"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"因为 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vuex4.x"}]},{"type":"text","value":" 目前还在一些写法上的问题，所以本项目使用了高适配 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue3"}]},{"type":"text","value":" 版本的 "},{"type":"element","tag":"a","props":{"href":"https://pinia.esm.dev/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"pinia"}]},{"type":"text","value":" 作为状态管理工具。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"安装"}]},{"type":"element","tag":"code","props":{"code":"yarn add pinia@^2.0.0-beta.2\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"yarn add pinia@^2.0.0-beta.2\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"使用技巧："}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"首先在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"store"}]},{"type":"text","value":" 目录下创建 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"index.ts"}]},{"type":"text","value":" 导出 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"pinia"}]},{"type":"text","value":" 实例"}]},{"type":"element","tag":"code","props":{"code":"import type { App } from \"vue\";\nimport { createPinia } from \"pinia\";\nconst store = createPinia();\n\nexport function setupStore(app: App<Element>) {\n  app.use(store);\n}\n\nexport { store };\n\n","language":"typescript"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import type { App } from \"vue\";\nimport { createPinia } from \"pinia\";\nconst store = createPinia();\n\nexport function setupStore(app: App<Element>) {\n  app.use(store);\n}\n\nexport { store };\n\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"接着创建 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"moudle"}]},{"type":"text","value":" 目录，然后创建 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"app.ts"}]}]},{"type":"element","tag":"code","props":{"code":"import { defineStore } from \"pinia\";\nimport { store } from \"..\";\n// state interface\ninterface AppState {\n  count: number;\n}\n\nexport const useAppStore = defineStore({\n  id: \"pinia-app\",\n  state: (): AppState => ({\n    count: 1,\n  }),\n  getters: {\n    getCount(): number {\n      return this.count;\n    },\n  },\n  // async is supported\n  actions: {\n    DOUBLE_COUNT() {\n      this.count *= 2;\n    },\n  },\n});\n\nexport function useAppStoreHook() {\n  return useAppStore(store);\n}\n\n","language":"typescript"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"import { defineStore } from \"pinia\";\nimport { store } from \"..\";\n// state interface\ninterface AppState {\n  count: number;\n}\n\nexport const useAppStore = defineStore({\n  id: \"pinia-app\",\n  state: (): AppState => ({\n    count: 1,\n  }),\n  getters: {\n    getCount(): number {\n      return this.count;\n    },\n  },\n  // async is supported\n  actions: {\n    DOUBLE_COUNT() {\n      this.count *= 2;\n    },\n  },\n});\n\nexport function useAppStoreHook() {\n  return useAppStore(store);\n}\n\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"在 SFC 中使用也很简单，案例："}]},{"type":"element","tag":"code","props":{"code":"<template>\n  <p>\n    Click the button to test actions !\n    <button type=\"button\" @click=\"doubleCount\">count is: {{ count }}</button>\n  </p>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent, reactive, computed, toRefs } from \"vue\";\nimport { useAppStoreHook } from \"@/store/module/app\";\nexport default defineComponent({\n  name: \"Vuex\",\n  setup: () => {\n    const piniaApp = useAppStoreHook();\n\n    const state = reactive({\n      count: computed(() => piniaApp.count),\n    });\n\n    const doubleCount = () => {\n      piniaApp.DOUBLE_COUNT();\n    };\n\n    return {\n      ...toRefs(state),\n      doubleCount,\n    };\n  },\n});\n</script>\n","language":"vue"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"<template>\n  <p>\n    Click the button to test actions !\n    <button type=\"button\" @click=\"doubleCount\">count is: {{ count }}</button>\n  </p>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent, reactive, computed, toRefs } from \"vue\";\nimport { useAppStoreHook } from \"@/store/module/app\";\nexport default defineComponent({\n  name: \"Vuex\",\n  setup: () => {\n    const piniaApp = useAppStoreHook();\n\n    const state = reactive({\n      count: computed(() => piniaApp.count),\n    });\n\n    const doubleCount = () => {\n      piniaApp.DOUBLE_COUNT();\n    };\n\n    return {\n      ...toRefs(state),\n      doubleCount,\n    };\n  },\n});\n</script>\n"}]}]}]},{"type":"element","tag":"blockquote","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"更多使用技巧，查看 "},{"type":"element","tag":"a","props":{"href":"https://pinia.esm.dev/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"pinia文档"}]},{"type":"text","value":" 即可"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"axios"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"安装 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"axios"}]},{"type":"text","value":" 插件，根据需求封装请求拦截器即可"}]},{"type":"element","tag":"h3","props":{"id":"代码规范"},"children":[{"type":"text","value":"代码规范"}]},{"type":"element","tag":"h4","props":{"id":"集成-editorconfig"},"children":[{"type":"text","value":"集成 editorConfig"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"EditorConfig 有助于为跨各种编辑器和 IDE 处理同一项目的多个开发人员维护一致的编码风格。EditorConfig 项目由用于定义编码样式"},{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"的文件格式"}]},{"type":"text","value":"和一组"},{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"文本编辑器插件组成"}]},{"type":"text","value":"，这些"},{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"插件"}]},{"type":"text","value":"使编辑器能够读取文件格式并遵循定义的样式。EditorConfig 文件很容易阅读，并且可以很好地与版本控制系统配合使用。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"相关配置查看"},{"type":"element","tag":"a","props":{"href":"https://editorconfig.org/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"文档"}]},{"type":"text","value":"即可，VSCode需要下载相关插件搭配使用"}]},{"type":"element","tag":"code","props":{"code":"## Editor configuration, see http://editorconfig.org\n\n## 表示是最顶层的 EditorConfig 配置文件\nroot = true\n\n[*] ## 表示所有文件适用\ncharset = utf-8 ## 设置文件字符集为 utf-8\nindent_style = space ## 缩进风格（tab | space）\nindent_size = 2 ## 缩进大小\nend_of_line = lf ## 控制换行类型(lf | cr | crlf)\ntrim_trailing_whitespace = true ## 去除行首的任意空白字符\ninsert_final_newline = true ## 始终在文件末尾插入一个新行\n"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"## Editor configuration, see http://editorconfig.org\n\n## 表示是最顶层的 EditorConfig 配置文件\nroot = true\n\n[*] ## 表示所有文件适用\ncharset = utf-8 ## 设置文件字符集为 utf-8\nindent_style = space ## 缩进风格（tab | space）\nindent_size = 2 ## 缩进大小\nend_of_line = lf ## 控制换行类型(lf | cr | crlf)\ntrim_trailing_whitespace = true ## 去除行首的任意空白字符\ninsert_final_newline = true ## 始终在文件末尾插入一个新行\n"}]}]}]},{"type":"element","tag":"h4","props":{"id":"集成-prettier-配置"},"children":[{"type":"text","value":"集成 Prettier 配置"}]},{"type":"element","tag":"ol","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"命令行式 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"format"}]},{"type":"text","value":" ，需要项目中集成 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"prettier"}]},{"type":"text","value":" 加持"}]}]},{"type":"element","tag":"code","props":{"code":"yarn add prettier\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"yarn add prettier\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"然后在项目根目录创建 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".pretterrc"}]},{"type":"text","value":" 或者 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".pretterrc.json"}]},{"type":"text","value":" ,增加以下配置，了解更多配置见"},{"type":"element","tag":"a","props":{"href":"https://prettier.io/docs/en/options.html","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"文档"}]}]},{"type":"element","tag":"code","props":{"code":"{\n  \"useTabs\": false,\n  \"tabWidth\": 2,\n  \"printWidth\": 120,\n  \"singleQuote\": true,\n  \"bracketSpacing\": true,\n  \"semi\": true\n}\n\n","language":"json"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"{\n  \"useTabs\": false,\n  \"tabWidth\": 2,\n  \"printWidth\": 120,\n  \"singleQuote\": true,\n  \"bracketSpacing\": true,\n  \"semi\": true\n}\n\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"然后运行命令一键格式化，这一步可以被集成到打包或者编译前置动作"}]},{"type":"element","tag":"code","props":{"code":"yarn prettier --write .  \n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"yarn prettier --write .  \n"}]}]}]},{"type":"element","tag":"ol","props":{"start":2},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"利用编辑器插件 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"format"}]},{"type":"text","value":"\nVscode 提供 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"prettier"}]},{"type":"text","value":" 插件同样具有强大的能力，开发者不需要在项目中安装 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"prettier"}]},{"type":"text","value":" 就可以通过配置来实现 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"format"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"首先是插件市场安装 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"prettier"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"然后可以在本地 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"setting.json"}]},{"type":"text","value":"，或者项目目录下创建 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".vscode"}]},{"type":"text","value":"目录，然后创建 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"setting.json"}]},{"type":"text","value":"，加入以下配置"}]}]},{"type":"element","tag":"code","props":{"code":"{\n    // prettier配置\n  \"editor.detectIndentation\": false,\n  \"editor.formatOnSave\": true, // 开启自动保存\n  \"editor.codeActionsOnSave\": {\n    \"source.fixAll.eslint\": true\n  },\n  \"editor.defaultFormatter\": \"esbenp.prettier-vscode\",\n  \"[javascript]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  },\n  \"[html]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  },\n  \"[vue]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  },\n  \"[json]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  },\n   \"[jsx]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  },\n   \"[tsx]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  },\n  \"[css]\": {\n    \"editor.defaultFormatter\": \"michelemelluso.code-beautifier\"\n  },\n  \"[scss]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  },\n  \"[less]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  },\n  \"[typescript]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  }\n}\n","language":"json"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"{\n    // prettier配置\n  \"editor.detectIndentation\": false,\n  \"editor.formatOnSave\": true, // 开启自动保存\n  \"editor.codeActionsOnSave\": {\n    \"source.fixAll.eslint\": true\n  },\n  \"editor.defaultFormatter\": \"esbenp.prettier-vscode\",\n  \"[javascript]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  },\n  \"[html]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  },\n  \"[vue]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  },\n  \"[json]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  },\n   \"[jsx]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  },\n   \"[tsx]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  },\n  \"[css]\": {\n    \"editor.defaultFormatter\": \"michelemelluso.code-beautifier\"\n  },\n  \"[scss]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  },\n  \"[less]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  },\n  \"[typescript]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  }\n}\n"}]}]}]},{"type":"element","tag":"blockquote","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"工作区目录优先级比全局要高，推荐在工作区引入该配置"}]}]}]}]},{"type":"element","tag":"h4","props":{"id":"集成-eslint"},"children":[{"type":"text","value":"集成 Eslint"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"eslint"}]},{"type":"text","value":" 规则配置要比 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"tslint"}]},{"type":"text","value":" 要多的多，所以首选 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"eslint"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"第一步，安装 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"eslint"}]}]},{"type":"element","tag":"code","props":{"code":"yarn add eslint\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"yarn add eslint\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"相关插件列表"}]},{"type":"element","tag":"code","props":{"code":"{\n    \"@typescript-eslint/eslint-plugin\": \"^4.28.4\",\n    \"@typescript-eslint/parser\": \"^4.28.4\",\n    \"@vue/eslint-config-prettier\": \"^6.0.0\",\n    \"@vue/eslint-config-typescript\": \"^7.0.0\",\n    \"vue-eslint-parser\": \"^7.6.0\",\n    \"eslint\": \"^7.31.0\",\n    \"prettier\": \"^2.3.2\",\n    \"eslint-config-prettier\": \"^8.3.0\",\n    \"eslint-plugin-import\": \"^2.23.4\",\n    \"eslint-plugin-node\": \"^11.1.0\",\n    \"eslint-plugin-prettier\": \"^3.4.0\",\n    \"eslint-plugin-vue\": \"^7.14.0\",\n}\n","language":"json"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"{\n    \"@typescript-eslint/eslint-plugin\": \"^4.28.4\",\n    \"@typescript-eslint/parser\": \"^4.28.4\",\n    \"@vue/eslint-config-prettier\": \"^6.0.0\",\n    \"@vue/eslint-config-typescript\": \"^7.0.0\",\n    \"vue-eslint-parser\": \"^7.6.0\",\n    \"eslint\": \"^7.31.0\",\n    \"prettier\": \"^2.3.2\",\n    \"eslint-config-prettier\": \"^8.3.0\",\n    \"eslint-plugin-import\": \"^2.23.4\",\n    \"eslint-plugin-node\": \"^11.1.0\",\n    \"eslint-plugin-prettier\": \"^3.4.0\",\n    \"eslint-plugin-vue\": \"^7.14.0\",\n}\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"第二步，初始化规则，这里我选择了 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"eslint:recommended"}]}]},{"type":"element","tag":"code","props":{"code":"yarn eslint --init\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"yarn eslint --init\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"根据团队需求配置 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"eslint"}]},{"type":"text","value":" 规则"}]},{"type":"element","tag":"blockquote","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"解决 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"eslint"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"prettier"}]},{"type":"text","value":" 规则冲突问题"}]},{"type":"element","tag":"ol","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"安装 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"eslint-plugin-prettier"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"eslint-config-prettier"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".eskintrc.js"}]},{"type":"text","value":"添加顺序规则"},{"type":"element","tag":"code","props":{"code":"module.exports = {\n  ...\n  extends: [\n    'plugin:vue/essential',\n    'eslint:recommended',\n    'plugin:prettier/recommended' // 添加 prettier 插件\n  ],\n  ...\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"module.exports = {\n  ...\n  extends: [\n    'plugin:vue/essential',\n    'eslint:recommended',\n    'plugin:prettier/recommended' // 添加 prettier 插件\n  ],\n  ...\n}\n"}]}]}]},{"type":"element","tag":"br","props":{},"children":[]},{"type":"text","value":"最终优先级："},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Prettier 配置规则"}]},{"type":"text","value":" > "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"ESLint 配置规则"}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"fix"}]},{"type":"text","value":" 代码"}]},{"type":"element","tag":"code","props":{"code":"eslint --fix\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"eslint --fix\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"第三步，配置 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vscode"}]},{"type":"text","value":" 自动 fix：安装 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Eslint"}]},{"type":"text","value":" 插件，然后开启 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"autofix"}]}]},{"type":"element","tag":"code","props":{"code":" \"editor.codeActionsOnSave\": {\n    \"source.fixAll.eslint\": true\n }\n","language":"json"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":" \"editor.codeActionsOnSave\": {\n    \"source.fixAll.eslint\": true\n }\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"第四步，添加 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"script"}]}]},{"type":"element","tag":"code","props":{"code":"  \"scripts\": {\n    \"dev\": \"eslint --ext .js,.jsx,.vue,.ts,.tsx src && vite\",\n    \"build\": \"vue-tsc --noEmit && vite build\",\n    \"serve\": \"vite preview\",\n    \"lint\": \"eslint --ext .js,.jsx,.vue,.ts,.tsx src\"\n  },\n","language":"json"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"  \"scripts\": {\n    \"dev\": \"eslint --ext .js,.jsx,.vue,.ts,.tsx src && vite\",\n    \"build\": \"vue-tsc --noEmit && vite build\",\n    \"serve\": \"vite preview\",\n    \"lint\": \"eslint --ext .js,.jsx,.vue,.ts,.tsx src\"\n  },\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"贴一下我自己的"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".eslintrc.js"}]}]},{"type":"element","tag":"code","props":{"code":"module.exports = {\n  root: true,\n  env: {\n    node: true,\n  },\n  extends: ['plugin:vue/vue3-essential', 'eslint:recommended', '@vue/typescript/recommended'],\n  parserOptions: {\n    ecmaVersion: 2020,\n  },\n  rules: {\n    // disable the rule for all files\n    '@typescript-eslint/explicit-module-boundary-types': 'off',\n  },\n  overrides: [\n    {\n      // enable the rule specifically for TypeScript files\n      files: ['*.js', '*.ts'],\n      rules: {\n        '@typescript-eslint/explicit-module-boundary-types': 'warn',\n      },\n    },\n  ],\n};\n\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"module.exports = {\n  root: true,\n  env: {\n    node: true,\n  },\n  extends: ['plugin:vue/vue3-essential', 'eslint:recommended', '@vue/typescript/recommended'],\n  parserOptions: {\n    ecmaVersion: 2020,\n  },\n  rules: {\n    // disable the rule for all files\n    '@typescript-eslint/explicit-module-boundary-types': 'off',\n  },\n  overrides: [\n    {\n      // enable the rule specifically for TypeScript files\n      files: ['*.js', '*.ts'],\n      rules: {\n        '@typescript-eslint/explicit-module-boundary-types': 'warn',\n      },\n    },\n  ],\n};\n\n"}]}]}]},{"type":"element","tag":"h4","props":{"id":"提交修复"},"children":[{"type":"text","value":"提交修复"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"我们希望在代码提交之前做一次 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"lint"}]},{"type":"text","value":" 检查和修复，我们需要用到 Git Hook，在本地执行 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"git commit"}]},{"type":"text","value":" 的时候，就对所提交的代码进行 ESLint 检测和修复（即执行 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"eslint --fix"}]},{"type":"text","value":"），如果这些代码没通过 ESLint 规则校验，则禁止提交。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"这里需要使用到两个工具:"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/typicode/husky","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"husky"}]},{"type":"text","value":" —— Git Hook 工具，可以设置在 git 各个阶段（"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"pre-commit"}]},{"type":"text","value":"、"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"commit-msg"}]},{"type":"text","value":"、"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"pre-push"}]},{"type":"text","value":" 等）触发我们的命令。"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/okonet/lint-staged","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"lint-staged"}]},{"type":"text","value":" —— 在 git 暂存的文件上运行 linters。"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"第一步，安装插件并初始化一个 husky 配置，这一步会在根目录下生成 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".husky "}]},{"type":"text","value":"目录"}]},{"type":"element","tag":"code","props":{"code":"npx husky-init && yarn\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"npx husky-init && yarn\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"第二步，修改 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"pre-commit"}]},{"type":"text","value":"规则，但缺点是这一步会扫描所有文件"}]},{"type":"element","tag":"code","props":{"code":"##!/bin/sh\n. \"$(dirname \"$0\")/_/husky.sh\"\n\neslint --fix ./src --ext .vue,.js,.ts\n","language":"bash"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"##!/bin/sh\n. \"$(dirname \"$0\")/_/husky.sh\"\n\neslint --fix ./src --ext .vue,.js,.ts\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"image-20210723150047244","src":"https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/e8519380eda14665b37258d8ad969c2a~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"第三步，安装并配置"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"lint-staged"}]}]},{"type":"element","tag":"code","props":{"code":"yarn add lint-staged\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"yarn add lint-staged\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"然后在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"package.json"}]},{"type":"text","value":"里增加 lint-staged 配置项"}]},{"type":"element","tag":"code","props":{"code":"  \"lint-staged\": {\n    \"*.{vue,js,ts,tsx,jsx}\": \"eslint --fix\"\n  }\n","language":"json"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"  \"lint-staged\": {\n    \"*.{vue,js,ts,tsx,jsx}\": \"eslint --fix\"\n  }\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"验证效果，我写了一段错误代码在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"demo.ts"}]},{"type":"text","value":"，然后去提交代码，husky 和 lint-staged 就起了关键作用，如果是 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"warning"}]},{"type":"text","value":" 级别可以正确修复，如果是 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"error"}]},{"type":"text","value":" 就会在控制台打印出错误日志"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"image-20210723151610043","src":"https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/e43a63987ee54443b9d7f0db93c4d51a~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]}]},{"type":"element","tag":"h3","props":{"id":"单元测试"},"children":[{"type":"text","value":"单元测试"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"单元测试是项目开发中一个非常重要的环节，完整的测试能为代码和业务提供质量保证，减少 Bug 的出现"}]},{"type":"element","tag":"h4","props":{"id":"安装并配置核心依赖"},"children":[{"type":"text","value":"安装并配置核心依赖"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/vuejs/vue-test-utils-next","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"vue-test-utils"}]}]},{"type":"text","value":" Vue 团队开发和维护的测试库"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/facebook/jest","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"jest"}]}]},{"type":"text","value":" 官方推荐测试库"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/vuejs/vue-jest","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"vue-jest"}]}]},{"type":"text","value":" 负责 jest  扫描 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".vue"}]},{"type":"text","value":" 和转换"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/kulshekhar/ts-jest","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"ts-jest"}]}]},{"type":"text","value":" 负责 jest 扫描 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".ts"}]},{"type":"text","value":" 和转换"}]}]},{"type":"element","tag":"code","props":{"code":"yarn add @vue/test-utils@next jest vue-jest@next ts-jest -D    \n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"yarn add @vue/test-utils@next jest vue-jest@next ts-jest -D    \n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"添加 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"jest.config.js"}]}]},{"type":"element","tag":"code","props":{"code":"module.exports = {\n  moduleFileExtensions: ['vue', 'js', 'ts'],\n  preset: 'ts-jest',\n  testEnvironment: 'jsdom',\n  transform: {\n    '^.+\\\\.vue$': 'vue-jest', // vue 文件用 vue-jest 转换\n    '^.+\\\\.ts$': 'ts-jest', // ts 文件用 ts-jest 转换\n  },\n  // 匹配 __tests__ 目录下的 .js/.ts 文件 或其他目录下的 xx.test.js/ts xx.spec.js/ts\n  testRegex: '(/__tests__/.*|(\\\\.|/)(test|spec))\\\\.(ts)$',\n};\n\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"module.exports = {\n  moduleFileExtensions: ['vue', 'js', 'ts'],\n  preset: 'ts-jest',\n  testEnvironment: 'jsdom',\n  transform: {\n    '^.+\\\\.vue$': 'vue-jest', // vue 文件用 vue-jest 转换\n    '^.+\\\\.ts$': 'ts-jest', // ts 文件用 ts-jest 转换\n  },\n  // 匹配 __tests__ 目录下的 .js/.ts 文件 或其他目录下的 xx.test.js/ts xx.spec.js/ts\n  testRegex: '(/__tests__/.*|(\\\\.|/)(test|spec))\\\\.(ts)$',\n};\n\n"}]}]}]},{"type":"element","tag":"h4","props":{"id":"集成typesjest-和-eslint-plugin-jest"},"children":[{"type":"text","value":"集成@types/jest 和 eslint-plugin-jest"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"这两个工具主要是为了解决编辑器 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"jest"}]},{"type":"text","value":" 代码提示错误和 eslint 对 jest 的支持"}]},{"type":"element","tag":"code","props":{"code":"yarn add @types/jest eslint-plugin-jest -D\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"yarn add @types/jest eslint-plugin-jest -D\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"修改 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"tsconfig.json"}]}]},{"type":"element","tag":"code","props":{"code":"{\n  \"compilerOptions\": {\n    ...\n    \"types\": [\"vite/client\", \"jest\"]\n  },\n}\n","language":"json"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"{\n  \"compilerOptions\": {\n    ...\n    \"types\": [\"vite/client\", \"jest\"]\n  },\n}\n"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".eslintrc.js"}]},{"type":"text","value":" 添加 jest lint 插件 配置"}]},{"type":"element","tag":"code","props":{"code":"{\n  ...\n    extends: [\n    'plugin:vue/vue3-essential',\n    'eslint:recommended',\n    '@vue/typescript/recommended',\n    'plugin:jest/recommended',\n  ],\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"{\n  ...\n    extends: [\n    'plugin:vue/vue3-essential',\n    'eslint:recommended',\n    '@vue/typescript/recommended',\n    'plugin:jest/recommended',\n  ],\n}\n"}]}]}]},{"type":"element","tag":"h4","props":{"id":"编写单元测试"},"children":[{"type":"text","value":"编写单元测试"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"创建 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"tests"}]},{"type":"text","value":" 目录，然后创建 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"xx.spec.ts"}]},{"type":"text","value":" 文件编写单元测试，然后测试"}]},{"type":"element","tag":"code","props":{"code":"// Axios.spec.ts\nimport { mount } from '@vue/test-utils';\nimport Axios from '../src/views/Axios.vue';\n\ndescribe('Axios.vue', () => {\n  it('renders', () => {\n    const wrapper = mount(Axios);\n    expect(wrapper.html()).toContain('Vite2.x + Vue3.x + TypeScript Starter');\n  });\n});\n\n","language":"typescript"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"text","value":"// Axios.spec.ts\nimport { mount } from '@vue/test-utils';\nimport Axios from '../src/views/Axios.vue';\n\ndescribe('Axios.vue', () => {\n  it('renders', () => {\n    const wrapper = mount(Axios);\n    expect(wrapper.html()).toContain('Vite2.x + Vue3.x + TypeScript Starter');\n  });\n});\n\n"}]}]}]},{"type":"element","tag":"blockquote","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"建议打包时执行前置单元测试，如果希望在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"push"}]},{"type":"text","value":" 代码之前执行单元测试，只需要在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".husky"}]},{"type":"text","value":" 目录下创建 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"pre-push"}]},{"type":"text","value":"脚本 ，然后添加对应测试命令即可。"}]}]},{"type":"element","tag":"h2","props":{"id":"小结"},"children":[{"type":"text","value":"小结"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"至此，一个综合性 Vue3.x 项目就搭建完成，总结下该工程的能力"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"编程语言："},{"type":"element","tag":"a","props":{"href":"https://www.typescriptlang.org/zh/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"TypeScript"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"构建工具："},{"type":"element","tag":"a","props":{"href":"https://cn.vitejs./dev/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Vite 2.x"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"前端框架："},{"type":"element","tag":"a","props":{"href":"https://v3.cn.vuejs.org/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Vue 3.x"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"路由工具："},{"type":"element","tag":"a","props":{"href":"https://next.router.vuejs.org/zh/index.html","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Vue Router 4.x"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"状态管理："},{"type":"element","tag":"a","props":{"href":"https://pinia.esm.dev/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Pinia"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"CSS 预编译："},{"type":"element","tag":"a","props":{"href":"https://stylus-lang.com/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Stylus"}]},{"type":"text","value":" / "},{"type":"element","tag":"a","props":{"href":"https://sass.bootcss.com/documentation","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Sass"}]},{"type":"text","value":" / "},{"type":"element","tag":"a","props":{"href":"http://lesscss.cn/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Less"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"HTTP 工具："},{"type":"element","tag":"a","props":{"href":"https://axios-http.com/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Axios"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Git Hook 工具："},{"type":"element","tag":"a","props":{"href":"https://typicode.github.io/husky/##/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"husky"}]},{"type":"text","value":" + "},{"type":"element","tag":"a","props":{"href":"https://github.com/okonet/lint-staged","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"lint-staged"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"代码规范："},{"type":"element","tag":"a","props":{"href":"http://editorconfig.org/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"EditorConfig"}]},{"type":"text","value":" + "},{"type":"element","tag":"a","props":{"href":"https://prettier.io/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Prettier"}]},{"type":"text","value":" + "},{"type":"element","tag":"a","props":{"href":"https://eslint.org/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"ESLint"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"单元测试："},{"type":"element","tag":"a","props":{"href":"https://next.vue-test-utils.vuejs.org/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"vue-test-utils"}]},{"type":"text","value":" + "},{"type":"element","tag":"a","props":{"href":"https://jestjs.io/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"jest"}]},{"type":"text","value":" + "},{"type":"element","tag":"a","props":{"href":"https://github.com/vuejs/vue-jest","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"vue-jest"}]},{"type":"text","value":" + "},{"type":"element","tag":"a","props":{"href":"https://kulshekhar.github.io/ts-jest/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"ts-jest"}]}]}]},{"type":"element","tag":"blockquote","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"在线预览该工程："},{"type":"element","tag":"a","props":{"href":"https://251205668.github.io/vite-vue3-sfc-template/##/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"vite-vue3-sfc-template"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"为此我还准备了这些常用模板"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Vue2.x + vite 模板"},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"TSX + decorator能力："},{"type":"element","tag":"a","props":{"href":"https://github.com/251205668/vite-vue2-start/tree/tsx-decorator","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"vite-vue2-tsx-start"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"SFC + decorator能力："},{"type":"element","tag":"a","props":{"href":"https://github.com/251205668/vite-vue2-start","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"vite-vue2-start"}]}]}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Vue3.x + vite 模板"},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"TSX + composition-api能力："},{"type":"element","tag":"a","props":{"href":"https://github.com/251205668/vite-vue3-start","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"vite-vue3-start"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"SFC + composition-api能力："},{"type":"element","tag":"a","props":{"href":"https://github.com/251205668/vite-vue3-sfc-template","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"vite-vue3-sfc-template"}]}]}]}]}]}]}]},"publishedAt":"2021-07-25","status":"published","tags":["webpack","vite"],"body":{"type":"root","children":[{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"toc","props":{},"children":[]}]},{"type":"element","tag":"h2","props":{"id":"vite-概要介绍"},"children":[{"type":"text","value":"Vite 概要介绍"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"📚： "},{"type":"element","tag":"a","props":{"href":"https://vitejs.dev/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"官方文档"}]},{"type":"text","value":"，"},{"type":"element","tag":"a","props":{"href":"https://cn.vitejs.dev/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"中文文档"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"🔨： "},{"type":"element","tag":"a","props":{"href":""},"children":[{"type":"text","value":"常用设置文档"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"🧰： "},{"type":"element","tag":"a","props":{"href":""},"children":[{"type":"text","value":"API 文档"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"⛄：插件和其生态 - "},{"type":"element","tag":"a","props":{"href":"https://github.com/vitejs/awesome-vite##plugins","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"awesome-vite"}]}]}]},{"type":"element","tag":"h3","props":{"id":"什么是-vite"},"children":[{"type":"text","value":"什么是 Vite"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"在浏览器支持 ES 模块之前，JavaScript 并没有提供的原生机制让开发者以模块化的方式进行开发。"}]},{"type":"element","tag":"blockquote","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"这句话的意思其实就是浏览器以前不直接支持我们习惯写的 ES Moudle 语法，现在支持了，vite 充分利用了这一点。"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"之前针对这一问题，出现了各类的打包工具： "},{"type":"element","tag":"a","props":{"href":"https://webpack.js.org/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"webpack"}]},{"type":"text","value":"、"},{"type":"element","tag":"a","props":{"href":"https://rollupjs.org/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Rollup"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"a","props":{"href":"https://parceljs.org/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Parcel"}]},{"type":"text","value":" 等，这些工具说白了就是在干一件事 - 使用工具抓取、处理并将我们的源码模块串联成可以在浏览器中运行的文件。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"但是逐渐当我们的项目逐渐变得庞大起来，JS 文件变得很多很多，一个完整应用拥有的模块拥有几千个模块，这些构建工具的弊端就会展现出来。使用 JavaScript 开发的工具通常需要很长时间（甚至是几分钟！）才能启动开发服务器，即使使用 HMR，文件修改后的效果也需要几秒钟才能在浏览器中反映出来。如此循环往复，迟钝的反馈会极大地影响开发者的开发效率和幸福感。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"这些问题就成了 Vite 诞生的导火索。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"个人理解 Vite 的定义："}]},{"type":"element","tag":"blockquote","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Vite，一个基于浏览器原生 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"ES imports"}]},{"type":"text","value":" 的开发服务器。利用浏览器去解析 imports，在服务器端按需编译返回，完全跳过了打包这个概念，服务器随起随用。同时不仅有 Vue 文件支持，还搞定了热更新，而且热更新的速度不会随着模块增多而变慢。针对生产环境则可以把同一份代码用 rollup 打包。"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"使用 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vite"}]},{"type":"text","value":"  之后"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"html","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"<div id=\"app\"></div>\n<script type=\"module\">\n  import { createApp } from \"vue\";\n  import Main from \"./Main.vue\";\n\n  createApp(Main).mount(\"##app\");\n</script>\n","language":"html"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"div"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"id"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"app"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"></"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"div"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"type"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"module"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"createApp"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" Main "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"./Main.vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"createApp"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"(Main)"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"mount"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"##app"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]}]}]}]}]},{"type":"element","tag":"Image","props":{"alt":"preview","src":"https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/40d8c18b3052404182d62ae24803a663~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]},{"type":"element","tag":"h3","props":{"id":"vite-和-webpack-对比"},"children":[{"type":"text","value":"Vite 和 webpack 对比"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"webpack 和 Vite "},{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"构建模式"}]},{"type":"text","value":"截然不同，在浏览器没有支持模块化的时候，期望将所有源代码编译进一个 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"js"}]},{"type":"text","value":" 文件中，然后提供给浏览器使用。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"所以在开发中运行启动命令的时候，webpack 总是需要从入口文件索引到整个项目的文件，下一步可能会采用代码拆分编译成一个或者多个单独的 JS 文件，这一步需要一次生成所有路由下的编译后文件，伴随着服务启动的时间随着项目复杂度指数增加。"}]},{"type":"element","tag":"Image","props":{"alt":"","src":"https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/833fec894776472ab23db760ce891c3c~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"那么 Vite 是如何解决问题的呢？Vite 会在本地帮你启动一个服务器，当浏览器读取到整个 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"html"}]},{"type":"text","value":" 文件之后，会执行到 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" 的时候才去向服务端发送对应模块的请求，Vite 内部进行模板解析，代码编译等解析成浏览器可以执行的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"JS"}]},{"type":"text","value":" 文件返回到浏览器端，这里就是真正的按需加载，并且不会因为模块增多而变慢。"}]},{"type":"element","tag":"Image","props":{"alt":"img","src":"https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/09a8b06e9d8842498e60764e3ee7dcdc~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]},{"type":"element","tag":"h3","props":{"id":"vite-带来的收益是什么"},"children":[{"type":"text","value":"Vite 带来的收益是什么"}]},{"type":"element","tag":"ol","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"开发环境启服务器速度飞快"}]},{"type":"element","tag":"blockquote","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"构建工具为 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Webpack"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"服务器启动速度，启动时间随着模块数增多而变慢"}]}]},{"type":"element","tag":"br","props":{},"children":[]},{"type":"element","tag":"Image","props":{"alt":"image-20210723152046683","src":"https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/7590ea884fd94087a310fa9aa3f87b24~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]},{"type":"element","tag":"br","props":{},"children":[]},{"type":"element","tag":"Image","props":{"alt":"image-20210719184638199","src":"https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/5c8420a5817b4d098d2c7d8c5ed9a6b8~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]},{"type":"element","tag":"blockquote","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"构建工具为 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vite"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"服务器启动速度，相较于前者快了将近十几倍，而且测试项目的模块数目并不多，只有几个模块。如果是一个较大的工程项目，包含几百个几千个模块，"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vite"}]},{"type":"text","value":" 启动服务器的速度将会是 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"webpack"}]},{"type":"text","value":"的几千倍"}]}]},{"type":"element","tag":"br","props":{},"children":[]},{"type":"element","tag":"Image","props":{"alt":"image-20210719184216175","src":"https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/a957a192a71748ea9a15acadab1d62a6~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"几乎实时的模块热更新"}]},{"type":"element","tag":"br","props":{},"children":[]},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"webpack"}]},{"type":"text","value":" 热更新也是需要重新编译一遍所有模块，然后启动服务器的，换句话来说 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"webpack"}]},{"type":"text","value":" 的热更新速度和初次编译启动时间相差不了多少，这样会给开发者带来一些负面的体验感，比如你在改动一个组件样式之后，可能需要等待很长一段时间页面才会重新渲染。"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vite"}]},{"type":"text","value":" 出现了，"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vite"}]},{"type":"text","value":"的热更新同样也运用到了 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"esbuild"}]},{"type":"text","value":" 的能力，可以准确的更新页面而无需重新加载页面或者删除应用程序状态。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"以上两点可以演示admin工程项目，和迁移admin工程项目对比速度"}]}]},{"type":"element","tag":"Image","props":{"alt":"img","src":"https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/7c3bc07073f144359acbd53e7b09018e~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]},{"type":"element","tag":"blockquote","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"实现原理: static server + compile + HMR"}]},{"type":"element","tag":"ol","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"当前目录作为静态文件服务器根目录"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"拦截部分文件请求(处理 import node_modules模块，处理 .Vue等文件的编译)"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"websocket 实现 HMR"}]}]}]},{"type":"element","tag":"ol","props":{"start":3},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"所需文件按需编译，避免编译用不到的文件"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"开箱即用，便面各种 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Loader"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Plugin"}]},{"type":"text","value":" 的配置"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Typescript - 内置支持"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"less/sass/postcss - 内置支持"}]}]}]}]},{"type":"element","tag":"h2","props":{"id":"vite-基础应用"},"children":[{"type":"text","value":"Vite 基础应用"}]},{"type":"element","tag":"h3","props":{"id":"官方脚手架安装模板安装"},"children":[{"type":"text","value":"官方脚手架安装、模板安装"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"shell","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"## npm\nnpm init @vitejs/app\n\n## yarn\nyarn create @vitejs/app\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"## npm"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"npm init @vitejs/app"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"## yarn"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"yarn create @vitejs/app"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"你还可以通过附加的命令行选项直接指定项目名称和你想要使用的模板。例如，要构建一个 Vite + Vue 项目，运行:"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"shell","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"## npm 6.x\nnpm init @vitejs/app my-vue-app --template vue\n\n## npm 7+, 需要额外的双横线：\nnpm init @vitejs/app my-vue-app -- --template vue\n\n## yarn\nyarn create @vitejs/app my-vue-app --template vue\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"## npm 6.x"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"npm init @vitejs/app my-vue-app --template vue"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"## npm 7+, 需要额外的双横线："}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"npm init @vitejs/app my-vue-app -- --template vue"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"## yarn"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"yarn create @vitejs/app my-vue-app --template vue"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"目前支持模板："}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vanilla"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vanilla-ts"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vue"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vue-ts"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"react"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"react-ts"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"preact"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"preact-ts"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"lit-element"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"lit-element-ts"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"svelte"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"svelte-ts"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Vue2+ts+vite 模板（暂时存在个人 github 上，且 tsc-decorator 分支还有bug）"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"shell","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"git clone https://github.com/251205668/vite-vue2-start\ncd vite-vue2-start\nyarn \nyarn dev\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"git clone https://github.com/251205668/vite-vue2-start"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"cd"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" vite-vue2-start"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"yarn "}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"yarn dev"}]}]}]}]}]}]},{"type":"element","tag":"h3","props":{"id":"vite-中使用-typescript"},"children":[{"type":"text","value":"Vite 中使用 Typescript"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Vite 天然支持 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".ts"}]},{"type":"text","value":" 文件，Vite 使用 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"esbuild"}]},{"type":"text","value":" 转译 TS 的速度将会是 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"tsc"}]},{"type":"text","value":" 的 20~30 倍，同时 HMR 更新速度将会小于 50 ms。"}]},{"type":"element","tag":"blockquote","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"编写项目时需要将 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"tsconfig.json"}]},{"type":"text","value":" 的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"compilerOptions"}]},{"type":"text","value":" 设置 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"isolateModules: true"}]},{"type":"text","value":", 这样 TS 才会警告你哪些功能无法与独立编译模式一同工作。"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"esbuild简介"}]}]},{"type":"element","tag":"Image","props":{"alt":"image-20210720160239282","src":"https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/4f97aa9980dc4edba478ce50a50b0851~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"为什么 esbuild 这么快，来自"},{"type":"element","tag":"a","props":{"href":"https://esbuild.github.io/faq/##why-is-esbuild-fast","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"官网解释"}]},{"type":"text","value":"，具体总结为以下几点："}]},{"type":"element","tag":"ol","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"使用 Go 编写，并且编译成了机器码"},{"type":"element","tag":"br","props":{},"children":[]},{"type":"text","value":"现在的构建工具一般都是用 JavaScript 进行编写的，对于这种解释型语言（动态语言）来说，在命令行下的性能非常糟糕。因为每次运行编译的时候 V8 引擎都是第一次遇见代码，无法进行任何优化措施。而 esbuild 使用 Go 这种编译型语言（静态语言）编写而成，已经编译成了机器可以直接执行的机器码。当 esbuild 在编译你的 javaScript 代码的时候，可能 Node 还在忙着解析你的构建工具的代码。"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"​       除此之外，Go 语言是为并发而设计的语言，而 JavaScript 明显不是（老单线程了）。"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Go 在线程之间共享使用内存空间，而 JS 想要在线程间传递数据还需要把数据序列化之后再传送。"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Go 和 JS 的并发都有相应的垃圾回收机制，Go 会在所有线程之间共享堆，对于 JS 而言，每一个线程都有一个独立的堆。"},{"type":"element","tag":"br","props":{},"children":[]},{"type":"text","value":"根据 esbuild 的作者的测试，这似乎将 JavaScript 的工作线程的并行处理能力减少了一半，可能是因为你的一半 CPU 核心忙于为另一半收集垃圾"}]}]},{"type":"element","tag":"ol","props":{"start":2},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"大量使用并行算法"},{"type":"element","tag":"br","props":{},"children":[]},{"type":"text","value":"除了 Go 语言天生对于并发的优势，使得其处理并发任务性能远远优于 JavaScript，\nEsbuild 的内部算法也是经过精心设计的，尽可能的压榨所有的 CPU 核心。"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"esbuild 的所有内容都是从零编写的"},{"type":"element","tag":"br","props":{},"children":[]},{"type":"text","value":"自己编写一切而不是使用第三方库有很多性能上的好处。可以从一开始就考虑到性能，可以确保所有的东西都使用一致的数据结构以避免昂贵的转换，当然，缺点就是这工作量非常大。"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"更有效利用内存"},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"esbuild 通过减少 AST 遍历次数（三次），来减小内存访问速度对于打包速度的影响"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Go 语言还有一个好处就是可以把数据更加紧凑的储存在内存中，从而使得高速 CPU 缓存可以存下更多的内容"}]}]}]}]},{"type":"element","tag":"h3","props":{"id":"vite-中使用-css"},"children":[{"type":"text","value":"Vite 中使用 CSS"}]},{"type":"element","tag":"ol","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"原生css 支持，这一点毋庸置疑"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/postcss/postcss/blob/main/docs/README-cn.md","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"postcss"}]},{"type":"text","value":" 支持"},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"变量定义"},{"type":"element","tag":"CodeBlock","props":{"data-language":"css","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"/* postcss 命名空间式定义变量 */\n:root {\n  --main-font-color: blue;\n}\n\n.root {\n  /* 使用postcss 插件console，但是需要配置 */  \n  @console.error error;\n  color: var(--main-font-color);\n}\n","language":"css"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"/* postcss 命名空间式定义变量 */"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"root"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  --main-font-color"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" blue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"root"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"/* 使用postcss 插件console，但是需要配置 */"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  @console.error error"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"color"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"var"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"--main-font-color"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":");"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"br","props":{},"children":[]},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"postcss.config.js"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"javascript","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"module.exports = {\n  plugins: [require(\"@postcss-plugins/console\")],\n};\n","language":"javascript"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"module.exports"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"plugins"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ["}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"require"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"@postcss-plugins/console"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"};"}]}]}]}]}]}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"@import"},{"type":"element","tag":"CodeBlock","props":{"data-language":"css","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"@import url(\"./test.css\");\n\n/* postcss 命名空间式定义变量 */\n:root {\n  --main-font-color: blue;\n}\n\n.root {\n  @console.error error;\n  color: var(--main-font-color);\n}\n\n","language":"css"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"@import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"url"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"./test.css"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":");"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"/* postcss 命名空间式定义变量 */"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"root"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  --main-font-color"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" blue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"root"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  @console.error error"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"color"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"var"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"--main-font-color"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":");"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"等等新功能特性"}]}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"css预处理器支持"},{"type":"element","tag":"br","props":{},"children":[]},{"type":"text","value":"Vite 也同时提供了对 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".scss"}]},{"type":"text","value":", "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".sass"}]},{"type":"text","value":", "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".less"}]},{"type":"text","value":", "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".styl"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".stylus"}]},{"type":"text","value":" 文件的内置支持。没有必要为它们安装特定的 Vite 插件，但必须安装相应的预处理器依赖："},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"scss"},{"type":"element","tag":"CodeBlock","props":{"data-language":"shell","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"yarn add scss\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"yarn add scss"}]}]}]}]}]}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"less"},{"type":"element","tag":"CodeBlock","props":{"data-language":"shell","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"yarn add less\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"yarn add less"}]}]}]}]}]}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"stylus"},{"type":"element","tag":"CodeBlock","props":{"data-language":"shell","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"yarn add stylus\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"yarn add stylus"}]}]}]}]}]}]}]}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/css-modules/css-modules","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"css-modules"}]},{"type":"text","value":" 支持"},{"type":"element","tag":"br","props":{},"children":[]},{"type":"text","value":"通常一个大型项目的页面样式名都希望是按模块来划分的，并且保证唯一性，Vite 内置了 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"css-modules"}]},{"type":"text","value":" 的功能"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"​       使用方式:  创建对应 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"*.module.css"}]},{"type":"text","value":" 然后引入即可，下图为测试的案例"}]},{"type":"element","tag":"Image","props":{"alt":"image-20210720173108971","src":"https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/e1da5116066e4a0ea1be10f534db926b~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]},{"type":"element","tag":"h3","props":{"id":"vite-集成-jsx-和-tsx"},"children":[{"type":"text","value":"Vite 集成 JSX 和 TSX"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".jsx"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".tsx"}]},{"type":"text","value":" 文件同样开箱即用。JSX 的转译同样是通过 "},{"type":"element","tag":"a","props":{"href":"https://esbuild.github.io/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"esbuild"}]},{"type":"text","value":"，Vue 3 用户配置 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"@vitejs/plugin-vue-jsx"}]},{"type":"text","value":" 即可"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"typescript","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"import { defineConfig } from \"vite\";\nimport vue from \"@vitejs/plugin-vue\";\nimport vuejsx from \"@vitejs/plugin-vue-jsx\";\n\n// https://vitejs.dev/config/\nexport default defineConfig({\n  plugins: [vue(), vuejsx({})],\n});\n\n","language":"typescript"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"defineConfig"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"vite"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" vue "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"@vitejs/plugin-vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" vuejsx "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"@vitejs/plugin-vue-jsx"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// https://vitejs.dev/config/"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"defineConfig"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"plugins"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ["}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"vuejsx"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]}]}]}]}]},{"type":"element","tag":"blockquote","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Vue2 版本需要单独引入 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vite-plugin-vue2"}]},{"type":"text","value":" 来配合 vite 工具，并且暂时不支持 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"tsx + decorator"}]},{"type":"text","value":" 写法，详情可以见"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"typescript","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"import { defineConfig } from \"vite\";\nimport { createVuePlugin } from \"vite-plugin-vue2\";\nimport ViteComponents from \"vite-plugin-components\";\nimport { resolve } from \"path\";\n\nconst config = defineConfig({\n  resolve: {\n    alias: {\n      \"@\": `${resolve(__dirname, \"src\")}`,\n    },\n  },\n  base: \"/vue-template/\",\n  build: {\n    minify: true,\n  },\n  plugins: [createVuePlugin({}), ViteComponents({ transformer: \"vue2\" })],\n  server: {\n    port: 8080,\n  },\n});\nexport default config;\n","language":"typescript"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"defineConfig"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"vite"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"createVuePlugin"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"vite-plugin-vue2"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ViteComponents "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"vite-plugin-components"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"resolve"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" config "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"defineConfig"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"resolve"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"alias"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"@"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"`${"}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"resolve"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"(__dirname"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"src"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}`"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"base"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/vue-template/"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"build"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"minify"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"true"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"plugins"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ["}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"createVuePlugin"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"ViteComponents"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"transformer"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"vue2"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"server"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"port"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"8080"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" config"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Vue2.x版本 SFC + TS 写法基本一致"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"vue","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"<template>\n  <div class=\"home\">\n    <img alt=\"Vue logo\" src=\"../assets/logo.png\" />\n    <HelloWorld msg=\"Welcome to Your Vue.js + TypeScript App\" />\n  </div>\n</template>\n\n<script lang=\"ts\">\nimport { Component, Vue } from \"vue-property-decorator\";\n\n@Component\nexport default class Home extends Vue {\n  ...\n}\n</script>\n","language":"vue"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"div"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"class"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"home"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"img"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"alt"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"Vue logo"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"src"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"../assets/logo.png"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" />"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"HelloWorld"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"msg"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"Welcome to Your Vue.js + TypeScript App"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" />"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  </"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"div"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"lang"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"ts"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"Component"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"Vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"vue-property-decorator"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"@"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"Component"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"class"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Home"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"extends"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"..."}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]}]}]}]}]}]},{"type":"element","tag":"h3","props":{"id":"viteconfigts-常用配置"},"children":[{"type":"text","value":"Vite.config.ts 常用配置"}]},{"type":"element","tag":"h4","props":{"id":"配置别名"},"children":[{"type":"text","value":"配置别名"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"typescript","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"export default defineConfig({\n  resolve: {\n    alias: {\n      // 路径映射开头必须要加/\n      \"@\": \"/src\",\n      \"@styles\": \"/src/styles\",\n    },\n  },\n});\n","language":"typescript"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"defineConfig"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"resolve"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"alias"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 路径映射开头必须要加/"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"@"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/src"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"@styles"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/src/styles"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"配置语法提示"}]}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"json","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"{\n  \"compilerOptions\": {\n    \"baseUrl\": \"./\",\n    \"paths\": {\n      \"@/*\": [\"src/*\"],\n      \"@styles/*\": [\"src/styles/*\"]\n    }\n  },\n  \"include\": [\"src/**/*.ts\", \"src/**/*.d.ts\", \"src/**/*.tsx\", \"src/**/*.vue\"]\n}\n","language":"json"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"compilerOptions"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"baseUrl"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"./"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"paths"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"@/*"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"["}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"src/*"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"],"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"@styles/*"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"["}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"src/styles/*"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"]"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"include"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"["}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"src/**/*.ts"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"src/**/*.d.ts"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"src/**/*.tsx"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"src/**/*.vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"]"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"使用效果"}]},{"type":"element","tag":"Image","props":{"alt":"image-20210720162535915","src":"https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/5372ce161b4f41b2ad3855486c0f1469~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]},{"type":"element","tag":"h4","props":{"id":"代理服务器"},"children":[{"type":"text","value":"代理服务器"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"typescript","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"export default {\n  proxy: {\n    '/api': {\n      target: 'http://doman1.com',\n      changeOrigin: true,\n      rewrite: path => path.replace(/^\\/api/, '')\n    }\n  }\n}\n\n","language":"typescript"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"proxy"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"/api"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"target"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"http://doman1.com"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"changeOrigin"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"true"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"rewrite"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" path "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"replace"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"/"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"^"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\/"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"api"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"/"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"''"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"具体使用"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"typescript","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"fetch('/api/users').then(...)\n","language":"typescript"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"fetch"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/api/users"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"then"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"..."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]}]}]}]}]}]},{"type":"element","tag":"h4","props":{"id":"数据mock"},"children":[{"type":"text","value":"数据mock"}]},{"type":"element","tag":"h4","props":{"id":"当前模式和环境变量"},"children":[{"type":"text","value":"当前模式和环境变量"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Vite 上定义好的环境变量"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"import.meta.env.MODE"}]}]},{"type":"text","value":": {string} 应用运行的"},{"type":"element","tag":"a","props":{"href":"https://cn.vitejs.dev/guide/env-and-mode.html##modes","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"模式"}]},{"type":"text","value":"。"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"import.meta.env.BASE_URL"}]}]},{"type":"text","value":": {string} 部署应用时的基本 URL。他由"},{"type":"element","tag":"a","props":{"href":"https://cn.vitejs.dev/config/##base","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"base"}]},{"type":"text","value":" 配置项"}]},{"type":"text","value":"决定。"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"import.meta.env.PROD"}]}]},{"type":"text","value":": {boolean} 应用是否运行在生产环境。"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"import.meta.env.DEV"}]}]},{"type":"text","value":": {boolean} 应用是否运行在开发环境 (永远与 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"import.meta.env.PROD"}]},{"type":"text","value":"相反)"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"自定义环境变量"}]}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"开发环境(git 管理)"},{"type":"element","tag":"CodeBlock","props":{"data-language":"env","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"// .env.development\nVITE_SOME_KEY=this is a development token\n","language":"env"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{}},"children":[{"type":"text","value":"// .env.development\nVITE_SOME_KEY=this is a development token"}]}]}]}]}]}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"生产环境(git 管理)"},{"type":"element","tag":"CodeBlock","props":{"data-language":"env","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"// .env.production\nVITE_SOME_KEY=this is a production token\n","language":"env"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{}},"children":[{"type":"text","value":"// .env.production\nVITE_SOME_KEY=this is a production token"}]}]}]}]}]}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"本地开发环境"},{"type":"element","tag":"CodeBlock","props":{"data-language":"env","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"// .env.development.local\nVITE_SOME_KEY=this is a development token but not managed by git\n","language":"env"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{}},"children":[{"type":"text","value":"// .env.development.local\nVITE_SOME_KEY=this is a development token but not managed by git"}]}]}]}]}]}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"本地生产环境"},{"type":"element","tag":"CodeBlock","props":{"data-language":"env","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"// .env.production.local\nVITE_SOME_KEY=this is a production token but not managed by git\n","language":"env"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{}},"children":[{"type":"text","value":"// .env.production.local\nVITE_SOME_KEY=this is a production token but not managed by git"}]}]}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"案例"}]}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"typescript","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":" return () => {\n      const mode = import.meta.env.MODE; // 模式\n      const baseUrl = import.meta.env.BASE_URL; //基本URL\n      const prod = import.meta.env.PROD; // 是否是生产环境\n      const dev = import.meta.env.DEV; // 是否是开发环境\n      const token = import.meta.env.VITE_SOME_KEY; // 自定义环境变量\n      return (\n        <div class=\"root\">\n          <p>当前模式：{mode}</p>\n          <p>当前baseURL：{baseUrl}</p>\n          <p>当前是否是生产环境：{prod}</p>\n          <p>当前是否是开发环境：{dev}</p>\n          <p>当前环境下token：{token}</p>\n        </div>\n      );\n    };\n","language":"typescript"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"mode"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"meta"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"env"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"MODE"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 模式"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"baseUrl"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"meta"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"env"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"BASE_URL"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//基本URL"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"prod"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"meta"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"env"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"PROD"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 是否是生产环境"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"dev"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"meta"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"env"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"DEV"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 是否是开发环境"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"token"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"meta"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"env"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"VITE_SOME_KEY"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 自定义环境变量"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"div"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"class"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"root"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"          <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"p"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":">"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"当前模式"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"："}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"mode"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"p"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"          <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"p"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":">"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"当前baseURL"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"："}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"baseUrl"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"p"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"          <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"p"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":">"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"当前是否是生产环境"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"："}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"prod"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"p"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"          <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"p"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":">"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"当前是否是开发环境"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"："}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"dev"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"p"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"          <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"p"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":">"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"当前环境下token"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"："}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"token"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"p"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"div"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      )"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"};"}]}]}]}]}]}]},{"type":"element","tag":"h3","props":{"id":"其他选项"},"children":[{"type":"text","value":"其他选项"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"详情可以见 "},{"type":"element","tag":"a","props":{"href":"https://cn.vitejs.dev/config/##shared-options","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"官方文档配置"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"此处列出一个自己玩过的模板"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"\n/**\n * https://vitejs.dev/config/\n * @type {import('vite').UserConfig}\n */\nexport default {\n    //项目根目录 \n    root: process.cwd(),\n    //项目部署的基础路径\n    base: \"/\",\n    //环境配置\n    mode: 'development',\n    //全局变量替换 Record<string, string>\n    define: {\n        \"\": \"\",\n        \"user\": \"users\",\n    },\n    //插件\n    plugins: [\n\n    ],\n    //静态资源服务的文件夹\n    publicDir: \"public\",\n\n    resolve: {\n        //别名\n        alias: {\n            \"@\": path.resolve(__dirname, \"/src\"),\n            \"comps\": path.resolve(__dirname, \"/src/components\")\n        },\n        dedupe: [],\n        //情景导出package.json配置中的exports 字段\n        conditions: [],\n        //解析package.json中的字段\n        mainFields: ['module', 'jsnext:main', 'jsnext'],\n        //导入时想要省略的扩展名列表\n        extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json']\n    },\n    css: {\n        //配置 CSS modules 的行为。选项将被传递给 postcss-modules。\n        modules: {\n\n        },\n        // PostCSS 配置（格式同 postcss.config.js）\n        // postcss-load-config 的插件配置\n        postcss: {\n\n        },\n        //指定传递给 CSS 预处理器的选项\n        preprocessorOptions: {\n            scss: {\n                additionalData: `$injectedColor: orange;`\n            }\n        }\n    },\n    json: {\n        //是否支持从 .json 文件中进行按名导入\n        namedExports: true,\n        //若设置为 true，导入的 JSON 会被转换为 export default JSON.parse(\"...\") 会比转译成对象字面量性能更好，\n        //尤其是当 JSON 文件较大的时候。\n        //开启此项，则会禁用按名导入\n        stringify: false\n    },\n    //继承自 esbuild 转换选项。最常见的用例是自定义 JSX\n    esbuild: {\n        jsxFactory: 'h',\n        jsxFragment: 'Fragment',\n        jsxInject: `import React from 'react'`\n    },\n    //静态资源处理  字符串|正则表达式\n    assetsInclude: '',\n    //调整控制台输出的级别 'info' | 'warn' | 'error' | 'silent'\n    logLevel: 'info',\n    //设为 false 可以避免 Vite 清屏而错过在终端中打印某些关键信息\n    clearScreen: true,\n    //服务\n    server: {\n        //服务器主机名\n        host: \"\",\n        //端口号\n        port: \"\",\n        //设为 true 时若端口已被占用则会直接退出，\n        //而不是尝试下一个可用端口\n        strictPort: true,\n        //https.createServer()配置项\n        https: \"\",\n        //服务器启动时自动在浏览器中打开应用程序。\n        //当此值为字符串时，会被用作 URL 的路径名\n        open: '/docs/index.html',\n        //自定义代理规则\n        proxy: {\n            // 字符串简写写法\n            '/foo': 'http://localhost:4567/foo',\n            // 选项写法\n            '/api': {\n                target: 'http://jsonplaceholder.typicode.com',\n                changeOrigin: true,\n                rewrite: (path) => path.replace(/^\\/api/, '')\n            },\n            // 正则表达式写法\n            '^/fallback/.*': {\n                target: 'http://jsonplaceholder.typicode.com',\n                changeOrigin: true,\n                rewrite: (path) => path.replace(/^\\/fallback/, '')\n            }\n        },\n        //开发服务器配置 CORS   \n        //boolean | CorsOptions\n        cors: {\n\n        },\n        //设置为 true 强制使依赖预构建\n        force: true,\n        //禁用或配置 HMR 连接\n        hmr: {\n\n        },\n        //传递给 chokidar 的文件系统监视器选项\n        watch: {\n\n        }\n    },\n    //构建\n    build: {\n        //浏览器兼容性  \"esnext\"|\"modules\"\n        target: \"modules\",\n        //输出路径\n        outDir: \"dist\",\n        //生成静态资源的存放路径\n        assetsDir: \"assets\",\n        //小于此阈值的导入或引用资源将内联为 base64 编码，以避免额外的 http 请求。设置为 0 可以完全禁用此项\n        assetsInlineLimit: 4096,\n        //启用/禁用 CSS 代码拆分\n        cssCodeSplit: true,\n        //构建后是否生成 source map 文件\n        sourcemap: false,\n        //自定义底层的 Rollup 打包配置\n        rollupOptions: {\n\n        },\n        //@rollup/plugin-commonjs 插件的选项\n        commonjsOptions: {\n\n        },\n        //构建的库\n        lib: {\n\n        },\n        //当设置为 true，构建后将会生成 manifest.json 文件\n        manifest: false,\n        //设置为 false 可以禁用最小化混淆，\n        //或是用来指定使用哪种混淆器\n        //boolean | 'terser' | 'esbuild'\n        minify: \"terser\",\n        //传递给 Terser 的更多 minify 选项。\n        terserOptions: {\n\n        },\n        //设置为 false 来禁用将构建后的文件写入磁盘\n        write: true,\n        //默认情况下，若 outDir 在 root 目录下，则 Vite 会在构建时清空该目录。\n        emptyOutDir: true,\n        //启用/禁用 brotli 压缩大小报告\n        brotliSize: true,\n        //chunk 大小警告的限制\n        chunkSizeWarningLimit: 500\n    },\n    //依赖优化选项\n    optimizeDeps: {\n        //检测需要预构建的依赖项\n        entries: [\n\n        ],\n        //预构建中强制排除的依赖项\n        exclude: [\n\n        ],\n        //默认情况下，不在 node_modules 中的，链接的包不会被预构建。使用此选项可强制预构建链接的包。\n        include: [\n\n        ]\n    },\n    //SSR 选项\n    ssr: {\n        //列出的是要为 SSR 强制外部化的依赖\n        external: [\n\n        ],\n        //列出的是防止被 SSR 外部化依赖项。\n        noExternal: [\n\n        ]\n    }\n}\n\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"/**"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":" * https://vitejs.dev/config/"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":" * "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"@"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"type"}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"import('vite').UserConfig"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":" */"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//项目根目录 "}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"root"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" process"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"cwd"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//项目部署的基础路径"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"base"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//环境配置"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"mode"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"development"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//全局变量替换 Record<string, string>"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"define"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"user"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"users"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//插件"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"plugins"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ["}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    ]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//静态资源服务的文件夹"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"publicDir"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"public"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"resolve"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//别名"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"alias"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"            "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"@"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"resolve"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"(__dirname"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/src"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"            "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"comps"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"resolve"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"(__dirname"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/src/components"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"dedupe"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" []"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//情景导出package.json配置中的exports 字段"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"conditions"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" []"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//解析package.json中的字段"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"mainFields"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ["}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"module"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"jsnext:main"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"jsnext"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//导入时想要省略的扩展名列表"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"extensions"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ["}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":".mjs"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":".js"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":".ts"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":".jsx"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":".tsx"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":".json"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"]"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"css"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//配置 CSS modules 的行为。选项将被传递给 postcss-modules。"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"modules"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// PostCSS 配置（格式同 postcss.config.js）"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// postcss-load-config 的插件配置"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"postcss"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//指定传递给 CSS 预处理器的选项"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"preprocessorOptions"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"            "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"scss"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"                "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"additionalData"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"`"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"$injectedColor: orange;"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"`"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"            "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"json"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//是否支持从 .json 文件中进行按名导入"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"namedExports"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"true"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//若设置为 true，导入的 JSON 会被转换为 export default JSON.parse(\"...\") 会比转译成对象字面量性能更好，"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//尤其是当 JSON 文件较大的时候。"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//开启此项，则会禁用按名导入"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"stringify"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"false"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//继承自 esbuild 转换选项。最常见的用例是自定义 JSX"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"esbuild"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"jsxFactory"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"h"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"jsxFragment"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"Fragment"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"jsxInject"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"`"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"import React from 'react'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"`"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//静态资源处理  字符串|正则表达式"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"assetsInclude"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"''"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//调整控制台输出的级别 'info' | 'warn' | 'error' | 'silent'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"logLevel"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"info"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//设为 false 可以避免 Vite 清屏而错过在终端中打印某些关键信息"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"clearScreen"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"true"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//服务"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"server"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//服务器主机名"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"host"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//端口号"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"port"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//设为 true 时若端口已被占用则会直接退出，"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//而不是尝试下一个可用端口"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"strictPort"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"true"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//https.createServer()配置项"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"https"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//服务器启动时自动在浏览器中打开应用程序。"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//当此值为字符串时，会被用作 URL 的路径名"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"open"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/docs/index.html"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//自定义代理规则"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"proxy"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"            "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 字符串简写写法"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"            "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"/foo"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"http://localhost:4567/foo"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"            "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 选项写法"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"            "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"/api"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"                "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"target"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"http://jsonplaceholder.typicode.com"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"                "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"changeOrigin"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"true"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"                "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"rewrite"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"replace"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"/"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"^"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\/"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"api"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"/"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"''"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"            "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"            "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 正则表达式写法"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"            "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"^/fallback/.*"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"                "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"target"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"http://jsonplaceholder.typicode.com"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"                "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"changeOrigin"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"true"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"                "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"rewrite"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"replace"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"/"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"^"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\/"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"fallback"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"/"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"''"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"            "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//开发服务器配置 CORS   "}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//boolean | CorsOptions"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"cors"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//设置为 true 强制使依赖预构建"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"force"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"true"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//禁用或配置 HMR 连接"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"hmr"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//传递给 chokidar 的文件系统监视器选项"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"watch"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//构建"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"build"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//浏览器兼容性  \"esnext\"|\"modules\""}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"target"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"modules"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//输出路径"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"outDir"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"dist"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//生成静态资源的存放路径"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"assetsDir"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"assets"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//小于此阈值的导入或引用资源将内联为 base64 编码，以避免额外的 http 请求。设置为 0 可以完全禁用此项"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"assetsInlineLimit"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"4096"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//启用/禁用 CSS 代码拆分"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"cssCodeSplit"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"true"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//构建后是否生成 source map 文件"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"sourcemap"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"false"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//自定义底层的 Rollup 打包配置"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"rollupOptions"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//@rollup/plugin-commonjs 插件的选项"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"commonjsOptions"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//构建的库"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"lib"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//当设置为 true，构建后将会生成 manifest.json 文件"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"manifest"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"false"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//设置为 false 可以禁用最小化混淆，"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//或是用来指定使用哪种混淆器"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//boolean | 'terser' | 'esbuild'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"minify"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"terser"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//传递给 Terser 的更多 minify 选项。"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"terserOptions"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//设置为 false 来禁用将构建后的文件写入磁盘"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"write"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"true"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//默认情况下，若 outDir 在 root 目录下，则 Vite 会在构建时清空该目录。"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"emptyOutDir"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"true"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//启用/禁用 brotli 压缩大小报告"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"brotliSize"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"true"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//chunk 大小警告的限制"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"chunkSizeWarningLimit"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"500"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//依赖优化选项"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"optimizeDeps"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//检测需要预构建的依赖项"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"entries"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ["}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        ]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//预构建中强制排除的依赖项"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"exclude"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ["}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        ]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//默认情况下，不在 node_modules 中的，链接的包不会被预构建。使用此选项可强制预构建链接的包。"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"include"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ["}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        ]"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//SSR 选项"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"ssr"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//列出的是要为 SSR 强制外部化的依赖"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"external"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ["}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        ]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"//列出的是防止被 SSR 外部化依赖项。"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"noExternal"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ["}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        ]"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"h3","props":{"id":"webpack-进军-vite"},"children":[{"type":"text","value":"webpack 进军 vite"}]},{"type":"element","tag":"h4","props":{"id":"如何迁移"},"children":[{"type":"text","value":"如何迁移"}]},{"type":"element","tag":"ol","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"首先需要入门 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vite"}]},{"type":"text","value":" 特性"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue2"}]},{"type":"text","value":" 版本迁移需要安装 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vite-plugin-vue2"}]},{"type":"text","value":" 插件，然后使用其暴露的 API  "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"createvuePlugin"}]},{"type":"text","value":" 让 Vite 能够正常编译运行。"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue3"}]},{"type":"text","value":" 版本就不列举~"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"删除一切 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vue-cli"}]},{"type":"text","value":" 插件和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"babel"}]},{"type":"text","value":" 插件，这里删除之后一定要注意检查哪一部分是否依赖于某个插件，如果插件依赖关系很强，针对这种场景 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vite"}]},{"type":"text","value":" 同样提供 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"rollup/babel"}]},{"type":"text","value":" 插件配置 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"babel"}]},{"type":"text","value":"。"},{"type":"element","tag":"blockquote","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Vue2.x 版本使用 babel 会有一个坑，因为依赖于 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vite-plugin-vue2"}]},{"type":"text","value":"，但是里面默认将读取 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".babelrc"}]},{"type":"text","value":" 配置关闭，这里需要手动改回来。"}]},{"type":"element","tag":"Image","props":{"alt":"image-20210721164134928","src":"https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/43eab40494a44694ba3fc755b11e7aee~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"dependencies"}]},{"type":"text","value":" 不用动，因为这些不会影响正常编译"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"查看"},{"type":"element","tag":"a","props":{"href":"https://cn.vitejs.dev/config/##config-file","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"文档配置"}]},{"type":"text","value":"，逐步将 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vue.config.js"}]},{"type":"text","value":" 迁移至 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vite.config.ts"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"环境变量迁移参考上述文档，准备 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"src/index.html"}]},{"type":"text","value":"，只需要改动启动入口 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"type = module"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"修改 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"script"}]},{"type":"text","value":"，修改为和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vite"}]},{"type":"text","value":" 相关脚本"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"个性化构建：因为 vite 内置构建工具为 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"rollup"}]},{"type":"text","value":"，所以如果需要对大型项目构建进行优化，可能会需要学习 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"rollup"}]},{"type":"text","value":"，当然 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vite"}]},{"type":"text","value":" 也提供了和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"webpack"}]},{"type":"text","value":" 构建配置相似的 "},{"type":"element","tag":"a","props":{"href":"https://cn.vitejs.dev/config/##build-options","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"API"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"如需配置 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"SSR"}]},{"type":"text","value":"，这一部分"},{"type":"element","tag":"a","props":{"href":"https://cn.vitejs.dev/config/##ssr-options","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"文档"}]},{"type":"text","value":"也有解释，但是目前 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vite"}]},{"type":"text","value":" 对 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"SSR"}]},{"type":"text","value":" 的支持还在探索"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"使用 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"composition-api"}]},{"type":"text","value":" ? 可以安装插件 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"@vue/composition-api"}]},{"type":"text","value":"，然后再入口文件 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue.use(VueCompositionAPI"}]},{"type":"text","value":" 即可"}]}]},{"type":"element","tag":"h4","props":{"id":"迁移踩过的坑"},"children":[{"type":"text","value":"迁移踩过的坑"}]},{"type":"element","tag":"ol","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"vue2 + vite2 + tsx 压根不支持 decorator 写法"},{"type":"element","tag":"br","props":{},"children":[]},{"type":"element","tag":"Image","props":{"alt":"image-20210721110601580","src":"https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/ebd849bf1eda4cfaa0f069c4184a9dfd~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"解决方案："}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"经过排查，原因已经确定，"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vite-plugin-vue2"}]},{"type":"text","value":" 的作者在设计初衷就希望编译走 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"esbuild"}]},{"type":"text","value":" 而不是走 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"babel"}]},{"type":"text","value":" ，所以他将入口文件读取"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".babelrc"}]},{"type":"text","value":" 默认关闭了，所以导致我怎么修改安装 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"babel"}]},{"type":"text","value":" 插件都无法生效。"}]},{"type":"element","tag":"blockquote","props":{},"children":[{"type":"element","tag":"ol","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"安装两个插件用于解析装饰器写法，并创建 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".babelrc"}]},{"type":"text","value":"加入以下配置"},{"type":"element","tag":"CodeBlock","props":{"data-language":"shell","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"yarn add @babel/plugin-proposal-decorators\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"yarn add @babel/plugin-proposal-decorators"}]}]}]}]}]}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"shell","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"yarn add @babel/plugin-proposal-class-properties\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"yarn add @babel/plugin-proposal-class-properties"}]}]}]}]}]}]},{"type":"element","tag":"code","props":{"code":"{\n  \"assumptions\": {\n    \"setPublicClassFields\": true\n  },\n  \"plugins\": [\n    [\"@babel/plugin-proposal-decorators\", { \"legacy\": true }],\n    [\"@babel/plugin-proposal-class-properties\"]\n  ]\n}\n   \n"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{}},"children":[{"type":"text","value":"{\n  \"assumptions\": {\n    \"setPublicClassFields\": true\n  },\n  \"plugins\": [\n    [\"@babel/plugin-proposal-decorators\", { \"legacy\": true }],\n    [\"@babel/plugin-proposal-class-properties\"]\n  ]\n}\n   "}]}]}]}]}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"开启 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vite-plugin-vue2"}]},{"type":"text","value":" 读取 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".babelrc"}]},{"type":"text","value":" 选项"},{"type":"element","tag":"br","props":{},"children":[]},{"type":"element","tag":"Image","props":{"alt":"image-20210721170737255","src":"https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/62468cf5139a487b91f82bc87141e6a8~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]}]}]}]},{"type":"element","tag":"ol","props":{"start":2},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Vite2 迁移需要将所有的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"CommonJS"}]},{"type":"text","value":" 替换成 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"ESM"}]},{"type":"text","value":" 写法，否则运行会报 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Uncaught ReferenceError: require is not defined"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Vite 应用的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"title"}]},{"type":"text","value":" 默认是写死的，如需要替换成实际的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"title"}]},{"type":"text","value":" 值需要安装 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vite-plugin-html"}]},{"type":"text","value":" 插件，然后通过 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"ejs"}]},{"type":"text","value":" 模板注入变量。"},{"type":"element","tag":"CodeBlock","props":{"data-language":"typescript","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"// vite.config.ts\nimport { defineConfig } from 'vite';\nimport { createVuePlugin } from 'vite-plugin-vue2';\n+ import { injectHtml } from 'vite-plugin-html';\n\nexport default defineConfig({\n  plugins: [\n    createVuePlugin(),\n+   injectHtml({\n+     injectData: {\n+       title: '用户管理系统',\n+     },\n    }),\n  ],\n  server: {\n    proxy,\n  },\n});\n","language":"typescript"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// vite.config.ts"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"defineConfig"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"vite"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"createVuePlugin"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"vite-plugin-vue2"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"+"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"injectHtml"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"vite-plugin-html"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"defineConfig"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"plugins"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ["}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"createVuePlugin"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"+"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"   "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"injectHtml"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"+     "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"injectData"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"+       "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"title"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"用户管理系统"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"+     "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  ]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"server"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    proxy"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]}]}]}]}]},{"type":"element","tag":"br","props":{},"children":[]},{"type":"text","value":"然后修改 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"index.html"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"html","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"<!DOCTYPE html>\n<html lang=\"en\">\n\n<head>\n  <meta charset=\"utf-8\">\n  <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n  <meta name=\"viewport\" content=\"width=device-width,initial-scale=1.0\">\n- <title><%= htmlWebpackPlugin.options.title %></title>\n+ <title><%= title %></title>\n</head>\n\n<body>\n  <noscript>\n-   We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled.\n+   We're sorry but <%= title %> doesn't work properly without JavaScript enabled.\n  </noscript>\n  <div id=\"app\"></div>\n  <script type=\"module\" src=\"/src/main.ts\"></script>\n</body>\n\n</html>\n\n","language":"html"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<!"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"DOCTYPE"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"html"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"html"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"lang"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"en"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"head"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"meta"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"charset"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"utf-8"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"meta"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"http-equiv"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"X-UA-Compatible"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"content"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"IE=edge"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"meta"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"name"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"viewport"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"content"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"width=device-width,initial-scale=1.0"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"- "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"title"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"<%= htmlWebpackPlugin.options.title %>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"title"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"+ "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"title"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"<%= title %>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"title"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"head"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"body"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"noscript"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"-   We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled."}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"+   We're sorry but <%= title %> doesn't work properly without JavaScript enabled."}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"noscript"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"div"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"id"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"app"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"></"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"div"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"type"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"module"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"src"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/src/main.ts"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"></"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"body"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"html"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]}]}]}]}]}]}]},{"type":"element","tag":"h2","props":{"id":"vite-常用插件"},"children":[{"type":"text","value":"Vite 常用插件"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Vite 插件依赖于 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Rollup"}]},{"type":"text","value":" 编写，未来将需要学习 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Rollup"}]},{"type":"text","value":" 插件编写"}]},{"type":"element","tag":"h3","props":{"id":"vitejsplugin-vue"},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/vitejs/vite/tree/main/packages/plugin-vue","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"@vitejs/plugin-vue"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"提供 Vue3 单文件组件支持"}]},{"type":"element","tag":"h3","props":{"id":"vitejsplugin-vue-jsx"},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/vitejs/vite/tree/main/packages/plugin-vue-jsx","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"@vitejs/plugin-vue-jsx"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"提供 Vue3 JSX 支持"}]},{"type":"element","tag":"h3","props":{"id":"vitejsplugin-legacy"},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/vitejs/vite/tree/main/packages/plugin-legacy","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"@vitejs/plugin-legacy"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"为打包后的文件提供传统浏览器兼容性支持"}]},{"type":"element","tag":"h3","props":{"id":"vitejsvite-plugin-vue2"},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/underfin/vite-plugin-vue2","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"@vitejs/vite-plugin-vue2"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"提供 Vue2 单文件组件支持，内置 JSX"}]},{"type":"element","tag":"h3","props":{"id":"vite-plugin-components"},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/antfu/vite-plugin-components","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"@vite-plugin-components"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"提供 Vue 组件自动导入功能，无需导入单文件组件"}]},{"type":"element","tag":"h2","props":{"id":"配合-vue3x-搭建工程化项目"},"children":[{"type":"text","value":"配合 Vue3.x 搭建工程化项目"}]},{"type":"element","tag":"h3","props":{"id":"搭建基础工程"},"children":[{"type":"text","value":"搭建基础工程"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"shell","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"yarn create @vitejs/app\n##npm\nnpm init @vitejs/app\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"yarn create @vitejs/app"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"##npm"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"npm init @vitejs/app"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"选择模板 vue-ts"}]},{"type":"element","tag":"Image","props":{"alt":"image-20210722104103443","src":"https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/3606756e1e9246ff978688bc059a2320~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]},{"type":"element","tag":"h3","props":{"id":"简单修改-vite-配置"},"children":[{"type":"text","value":"简单修改 vite 配置"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"简单配置以下路径代理、端口和打包路径"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"修改 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vite.config.ts"}]}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"typescript","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"export default defineConfig({\n  plugins: [vue()],\n  base: \"./\",\n  resolve: {\n    alias: {\n      \"@\": \"/src\",\n    },\n  },\n   server: {\n    port: 8080,\n    cors: true,\n  },\n});\n","language":"typescript"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"defineConfig"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"plugins"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ["}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"()]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"base"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"./"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"resolve"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"alias"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"@"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/src"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"   "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"server"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"port"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"8080"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"cors"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"true"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"路径代理之后附带修改一下 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"tsconfig.json"}]},{"type":"text","value":"，增加语法提示"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"json","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":" { \"compilerOptions\": {\n   ...\n    \"baseUrl\": \"./\",\n    \"paths\": {\n      \"@/*\": [\"src/*\"]\n    }\n  }\n }\n","language":"json"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"compilerOptions"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"   ..."}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"baseUrl"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"./"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"paths"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"@/*"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"["}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"src/*"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"]"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"如需配置接口代理，添加对应的 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"proxy"}]},{"type":"text","value":" 代理即可"}]},{"type":"element","tag":"h3","props":{"id":"整理目录结构"},"children":[{"type":"text","value":"整理目录结构"}]},{"type":"element","tag":"code","props":{"code":"├── .husky/                        // commit 前置hooks\n├── .vscode/                       // setting.json\n├── public/\n└── src/\n    ├── assets/                    // 静态资源及通用css目录\n    ├── common/                    // 通用组件目录\n    ├── constant/                  // 常量或枚举目录\n    ├── components/                // 业务组件目录\n    ├── router/                    // 路由配置目录\n    ├── store/                     // 状态管理目录\n    ├── utils/                     // 工具函数目录\n    ├── views/                     // 页面组件目录\n    ├── App.vue\n    ├── main.ts\n    ├── shims-vue.d.ts\n    ├── vite-env.d.ts\n├── tests/                         // 单元测试目录\n├── index.html\n├── tsconfig.json                  // TypeScript 配置文件\n├── .editorconfig                  // 编码风格 配置文件\n├── .eslintrc.js                   // Eslint 配置文件\n├── .eslintignore                  // Eslint 配置忽略文件\n├── .prettierrc.json                  // TypeScript 配置文件\n├── tsconfig.json                  // TypeScript 配置文件\n├── vite.config.ts                 // Vite 配置文件\n├── yarn.lock                \n└── package.json\n\n"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{}},"children":[{"type":"text","value":"├── .husky/                        // commit 前置hooks\n├── .vscode/                       // setting.json\n├── public/\n└── src/\n    ├── assets/                    // 静态资源及通用css目录\n    ├── common/                    // 通用组件目录\n    ├── constant/                  // 常量或枚举目录\n    ├── components/                // 业务组件目录\n    ├── router/                    // 路由配置目录\n    ├── store/                     // 状态管理目录\n    ├── utils/                     // 工具函数目录\n    ├── views/                     // 页面组件目录\n    ├── App.vue\n    ├── main.ts\n    ├── shims-vue.d.ts\n    ├── vite-env.d.ts\n├── tests/                         // 单元测试目录\n├── index.html\n├── tsconfig.json                  // TypeScript 配置文件\n├── .editorconfig                  // 编码风格 配置文件\n├── .eslintrc.js                   // Eslint 配置文件\n├── .eslintignore                  // Eslint 配置忽略文件\n├── .prettierrc.json                  // TypeScript 配置文件\n├── tsconfig.json                  // TypeScript 配置文件\n├── vite.config.ts                 // Vite 配置文件\n├── yarn.lock                \n└── package.json"}]}]}]}]}]},{"type":"element","tag":"h3","props":{"id":"整合部分工具"},"children":[{"type":"text","value":"整合部分工具"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"vue-router"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"安装支持 Vue3 的路由工具 vue-router@4"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"bash","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"yarn add vue-router@4\n","language":"bash"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"yarn add vue-router@4"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"创建 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"src/router/index.ts"}]},{"type":"text","value":" 文件"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"src"}]},{"type":"text","value":" 下创建 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"router"}]},{"type":"text","value":" 目录，然后在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"router"}]},{"type":"text","value":" 目录里新建 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"index.ts"}]},{"type":"text","value":" 文件："}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"typescript","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"import { createRouter, createWebHashHistory, RouteRecordRaw } from \"vue-router\";\nimport Home from \"@/views/Home.vue\";\nimport Pinia from \"@/views/pinia.vue\";\nimport VueRouter from \"@/views/vue-router.vue\";\nimport Axios from \"@/views/Axios.vue\";\nconst routes: Array<RouteRecordRaw> = [\n  {\n    path: \"/\",\n    name: \"Home\",\n    component: Home,\n  },\n  {\n    path: \"/pinia\",\n    name: \"Pinia\",\n    component: Pinia,\n  },\n  {\n    path: \"/vue-router\",\n    name: \"VueRouter\",\n    component: VueRouter,\n  },\n  {\n    path: \"/axios\",\n    name: \"axios\",\n    component: Axios,\n  },\n];\n\nconst router = createRouter({\n  history: createWebHashHistory(),\n  routes,\n});\n\nexport default router;\n","language":"typescript"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"createRouter"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"createWebHashHistory"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"RouteRecordRaw"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"vue-router"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" Home "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"@/views/Home.vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" Pinia "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"@/views/pinia.vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" VueRouter "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"@/views/vue-router.vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" Axios "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"@/views/Axios.vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" routes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Array"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"RouteRecordRaw"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ["}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"name"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"Home"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"component"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" Home"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/pinia"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"name"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"Pinia"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"component"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" Pinia"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/vue-router"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"name"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"VueRouter"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"component"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" VueRouter"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/axios"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"name"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"axios"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"component"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" Axios"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" router "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"createRouter"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"history"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"createWebHashHistory"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  routes"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" router"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"根据本项目路由配置的实际情况，你需要在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"src"}]},{"type":"text","value":" 下创建 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"views"}]},{"type":"text","value":" 目录，用来存储页面组件。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"main.ts"}]},{"type":"text","value":" 文件中挂载路由配置"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"ts","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"import { createApp } from 'vue'\nimport App from './App.vue'\nimport router from './router/index'\n\ncreateApp(App).use(router).mount('##app')\n","language":"ts"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"createApp"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" App "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"./App.vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" router "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"./router/index"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"createApp"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"(App)"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"use"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"(router)"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"mount"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"##app"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"Pinia"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"因为 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vuex4.x"}]},{"type":"text","value":" 目前还在一些写法上的问题，所以本项目使用了高适配 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Vue3"}]},{"type":"text","value":" 版本的 "},{"type":"element","tag":"a","props":{"href":"https://pinia.esm.dev/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"pinia"}]},{"type":"text","value":" 作为状态管理工具。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"安装"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"shell","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"yarn add pinia@^2.0.0-beta.2\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"yarn add pinia@^2.0.0-beta.2"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"使用技巧："}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"首先在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"store"}]},{"type":"text","value":" 目录下创建 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"index.ts"}]},{"type":"text","value":" 导出 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"pinia"}]},{"type":"text","value":" 实例"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"typescript","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"import type { App } from \"vue\";\nimport { createPinia } from \"pinia\";\nconst store = createPinia();\n\nexport function setupStore(app: App<Element>) {\n  app.use(store);\n}\n\nexport { store };\n\n","language":"typescript"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"type"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"App"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"createPinia"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"pinia"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" store "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"createPinia"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"setupStore"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"app"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"App"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"Element"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">)"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"app"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"use"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"store"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"store"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"};"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"接着创建 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"moudle"}]},{"type":"text","value":" 目录，然后创建 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"app.ts"}]}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"typescript","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"import { defineStore } from \"pinia\";\nimport { store } from \"..\";\n// state interface\ninterface AppState {\n  count: number;\n}\n\nexport const useAppStore = defineStore({\n  id: \"pinia-app\",\n  state: (): AppState => ({\n    count: 1,\n  }),\n  getters: {\n    getCount(): number {\n      return this.count;\n    },\n  },\n  // async is supported\n  actions: {\n    DOUBLE_COUNT() {\n      this.count *= 2;\n    },\n  },\n});\n\nexport function useAppStoreHook() {\n  return useAppStore(store);\n}\n\n","language":"typescript"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"defineStore"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"pinia"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"store"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":".."}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// state interface"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"interface"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"AppState"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"count"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"number"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" useAppStore "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"defineStore"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"id"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"pinia-app"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"state"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"():"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"AppState"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"count"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"1"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"getters"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"getCount"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"():"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"number"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"count"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// async is supported"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"actions"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"DOUBLE_COUNT"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"count"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"*="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"2"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"useAppStoreHook"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"useAppStore"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"store"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"在 SFC 中使用也很简单，案例："}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"vue","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"<template>\n  <p>\n    Click the button to test actions !\n    <button type=\"button\" @click=\"doubleCount\">count is: {{ count }}</button>\n  </p>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent, reactive, computed, toRefs } from \"vue\";\nimport { useAppStoreHook } from \"@/store/module/app\";\nexport default defineComponent({\n  name: \"Vuex\",\n  setup: () => {\n    const piniaApp = useAppStoreHook();\n\n    const state = reactive({\n      count: computed(() => piniaApp.count),\n    });\n\n    const doubleCount = () => {\n      piniaApp.DOUBLE_COUNT();\n    };\n\n    return {\n      ...toRefs(state),\n      doubleCount,\n    };\n  },\n});\n</script>\n","language":"vue"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"p"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"Click"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"the"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"button"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"to"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"test"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"actions"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" !"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"button"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"type"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"button"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"@"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"click"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"doubleCount"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"count"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"is:"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" {{ "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"count"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" }}</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"button"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  </"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"p"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"lang"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"ts"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"defineComponent"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"reactive"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"computed"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"toRefs"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"useAppStoreHook"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"@/store/module/app"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"defineComponent"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"name"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"Vuex"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"setup"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"piniaApp"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"useAppStoreHook"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"state"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"reactive"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      count"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"computed"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"piniaApp"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"count"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"doubleCount"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"piniaApp"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"DOUBLE_COUNT"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"};"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"..."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"toRefs"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"state"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"doubleCount"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"};"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]}]}]}]}]},{"type":"element","tag":"blockquote","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"更多使用技巧，查看 "},{"type":"element","tag":"a","props":{"href":"https://pinia.esm.dev/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"pinia文档"}]},{"type":"text","value":" 即可"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"axios"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"安装 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"axios"}]},{"type":"text","value":" 插件，根据需求封装请求拦截器即可"}]},{"type":"element","tag":"h3","props":{"id":"代码规范"},"children":[{"type":"text","value":"代码规范"}]},{"type":"element","tag":"h4","props":{"id":"集成-editorconfig"},"children":[{"type":"text","value":"集成 editorConfig"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"EditorConfig 有助于为跨各种编辑器和 IDE 处理同一项目的多个开发人员维护一致的编码风格。EditorConfig 项目由用于定义编码样式"},{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"的文件格式"}]},{"type":"text","value":"和一组"},{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"文本编辑器插件组成"}]},{"type":"text","value":"，这些"},{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"插件"}]},{"type":"text","value":"使编辑器能够读取文件格式并遵循定义的样式。EditorConfig 文件很容易阅读，并且可以很好地与版本控制系统配合使用。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"相关配置查看"},{"type":"element","tag":"a","props":{"href":"https://editorconfig.org/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"文档"}]},{"type":"text","value":"即可，VSCode需要下载相关插件搭配使用"}]},{"type":"element","tag":"code","props":{"code":"## Editor configuration, see http://editorconfig.org\n\n## 表示是最顶层的 EditorConfig 配置文件\nroot = true\n\n[*] ## 表示所有文件适用\ncharset = utf-8 ## 设置文件字符集为 utf-8\nindent_style = space ## 缩进风格（tab | space）\nindent_size = 2 ## 缩进大小\nend_of_line = lf ## 控制换行类型(lf | cr | crlf)\ntrim_trailing_whitespace = true ## 去除行首的任意空白字符\ninsert_final_newline = true ## 始终在文件末尾插入一个新行\n"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{}},"children":[{"type":"text","value":"## Editor configuration, see http://editorconfig.org\n\n## 表示是最顶层的 EditorConfig 配置文件\nroot = true\n\n[*] ## 表示所有文件适用\ncharset = utf-8 ## 设置文件字符集为 utf-8\nindent_style = space ## 缩进风格（tab | space）\nindent_size = 2 ## 缩进大小\nend_of_line = lf ## 控制换行类型(lf | cr | crlf)\ntrim_trailing_whitespace = true ## 去除行首的任意空白字符\ninsert_final_newline = true ## 始终在文件末尾插入一个新行"}]}]}]}]}]},{"type":"element","tag":"h4","props":{"id":"集成-prettier-配置"},"children":[{"type":"text","value":"集成 Prettier 配置"}]},{"type":"element","tag":"ol","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"命令行式 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"format"}]},{"type":"text","value":" ，需要项目中集成 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"prettier"}]},{"type":"text","value":" 加持"}]}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"shell","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"yarn add prettier\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"yarn add prettier"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"然后在项目根目录创建 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".pretterrc"}]},{"type":"text","value":" 或者 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".pretterrc.json"}]},{"type":"text","value":" ,增加以下配置，了解更多配置见"},{"type":"element","tag":"a","props":{"href":"https://prettier.io/docs/en/options.html","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"文档"}]}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"json","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"{\n  \"useTabs\": false,\n  \"tabWidth\": 2,\n  \"printWidth\": 120,\n  \"singleQuote\": true,\n  \"bracketSpacing\": true,\n  \"semi\": true\n}\n\n","language":"json"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"useTabs"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"false,"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"tabWidth"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"2"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"printWidth"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"120"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"singleQuote"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"true,"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"bracketSpacing"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"true,"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"semi"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"true"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"然后运行命令一键格式化，这一步可以被集成到打包或者编译前置动作"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"shell","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"yarn prettier --write .  \n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"yarn prettier --write "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]}]}]}]}]}]},{"type":"element","tag":"ol","props":{"start":2},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"利用编辑器插件 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"format"}]},{"type":"text","value":"\nVscode 提供 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"prettier"}]},{"type":"text","value":" 插件同样具有强大的能力，开发者不需要在项目中安装 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"prettier"}]},{"type":"text","value":" 就可以通过配置来实现 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"format"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"首先是插件市场安装 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"prettier"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"然后可以在本地 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"setting.json"}]},{"type":"text","value":"，或者项目目录下创建 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".vscode"}]},{"type":"text","value":"目录，然后创建 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"setting.json"}]},{"type":"text","value":"，加入以下配置"}]}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"json","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"{\n    // prettier配置\n  \"editor.detectIndentation\": false,\n  \"editor.formatOnSave\": true, // 开启自动保存\n  \"editor.codeActionsOnSave\": {\n    \"source.fixAll.eslint\": true\n  },\n  \"editor.defaultFormatter\": \"esbenp.prettier-vscode\",\n  \"[javascript]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  },\n  \"[html]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  },\n  \"[vue]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  },\n  \"[json]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  },\n   \"[jsx]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  },\n   \"[tsx]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  },\n  \"[css]\": {\n    \"editor.defaultFormatter\": \"michelemelluso.code-beautifier\"\n  },\n  \"[scss]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  },\n  \"[less]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  },\n  \"[typescript]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  }\n}\n","language":"json"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// prettier配置"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"editor.detectIndentation"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"false,"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"editor.formatOnSave"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"true,"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 开启自动保存"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"editor.codeActionsOnSave"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"source.fixAll.eslint"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"true"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"editor.defaultFormatter"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"esbenp.prettier-vscode"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"[javascript]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"editor.defaultFormatter"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"esbenp.prettier-vscode"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"[html]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"editor.defaultFormatter"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"esbenp.prettier-vscode"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"[vue]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"editor.defaultFormatter"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"esbenp.prettier-vscode"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"[json]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"editor.defaultFormatter"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"esbenp.prettier-vscode"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"   "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"[jsx]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"editor.defaultFormatter"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"esbenp.prettier-vscode"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"   "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"[tsx]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"editor.defaultFormatter"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"esbenp.prettier-vscode"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"[css]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"editor.defaultFormatter"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"michelemelluso.code-beautifier"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"[scss]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"editor.defaultFormatter"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"esbenp.prettier-vscode"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"[less]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"editor.defaultFormatter"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"esbenp.prettier-vscode"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"[typescript]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"editor.defaultFormatter"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"esbenp.prettier-vscode"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"blockquote","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"工作区目录优先级比全局要高，推荐在工作区引入该配置"}]}]}]}]},{"type":"element","tag":"h4","props":{"id":"集成-eslint"},"children":[{"type":"text","value":"集成 Eslint"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"eslint"}]},{"type":"text","value":" 规则配置要比 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"tslint"}]},{"type":"text","value":" 要多的多，所以首选 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"eslint"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"第一步，安装 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"eslint"}]}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"shell","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"yarn add eslint\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"yarn add eslint"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"相关插件列表"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"json","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"{\n    \"@typescript-eslint/eslint-plugin\": \"^4.28.4\",\n    \"@typescript-eslint/parser\": \"^4.28.4\",\n    \"@vue/eslint-config-prettier\": \"^6.0.0\",\n    \"@vue/eslint-config-typescript\": \"^7.0.0\",\n    \"vue-eslint-parser\": \"^7.6.0\",\n    \"eslint\": \"^7.31.0\",\n    \"prettier\": \"^2.3.2\",\n    \"eslint-config-prettier\": \"^8.3.0\",\n    \"eslint-plugin-import\": \"^2.23.4\",\n    \"eslint-plugin-node\": \"^11.1.0\",\n    \"eslint-plugin-prettier\": \"^3.4.0\",\n    \"eslint-plugin-vue\": \"^7.14.0\",\n}\n","language":"json"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"@typescript-eslint/eslint-plugin"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"^4.28.4"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"@typescript-eslint/parser"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"^4.28.4"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"@vue/eslint-config-prettier"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"^6.0.0"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"@vue/eslint-config-typescript"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"^7.0.0"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"vue-eslint-parser"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"^7.6.0"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"eslint"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"^7.31.0"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"prettier"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"^2.3.2"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"eslint-config-prettier"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"^8.3.0"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"eslint-plugin-import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"^2.23.4"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"eslint-plugin-node"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"^11.1.0"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"eslint-plugin-prettier"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"^3.4.0"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"eslint-plugin-vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"^7.14.0"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"第二步，初始化规则，这里我选择了 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"eslint:recommended"}]}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"shell","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"yarn eslint --init\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"yarn eslint --init"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"根据团队需求配置 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"eslint"}]},{"type":"text","value":" 规则"}]},{"type":"element","tag":"blockquote","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"解决 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"eslint"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"prettier"}]},{"type":"text","value":" 规则冲突问题"}]},{"type":"element","tag":"ol","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"安装 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"eslint-plugin-prettier"}]},{"type":"text","value":" 和 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"eslint-config-prettier"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".eskintrc.js"}]},{"type":"text","value":"添加顺序规则"},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"module.exports = {\n  ...\n  extends: [\n    'plugin:vue/essential',\n    'eslint:recommended',\n    'plugin:prettier/recommended' // 添加 prettier 插件\n  ],\n  ...\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"module.exports"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"..."}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  extends: ["}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"plugin:vue/essential"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"eslint:recommended"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"plugin:prettier/recommended"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 添加 prettier 插件"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  ]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"..."}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"br","props":{},"children":[]},{"type":"text","value":"最终优先级："},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Prettier 配置规则"}]},{"type":"text","value":" > "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"ESLint 配置规则"}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"fix"}]},{"type":"text","value":" 代码"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"shell","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"eslint --fix\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"eslint --fix"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"第三步，配置 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vscode"}]},{"type":"text","value":" 自动 fix：安装 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Eslint"}]},{"type":"text","value":" 插件，然后开启 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"autofix"}]}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"json","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":" \"editor.codeActionsOnSave\": {\n    \"source.fixAll.eslint\": true\n }\n","language":"json"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"editor.codeActionsOnSave"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":": "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"source.fixAll.eslint"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"true"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"第四步，添加 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"script"}]}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"json","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"  \"scripts\": {\n    \"dev\": \"eslint --ext .js,.jsx,.vue,.ts,.tsx src && vite\",\n    \"build\": \"vue-tsc --noEmit && vite build\",\n    \"serve\": \"vite preview\",\n    \"lint\": \"eslint --ext .js,.jsx,.vue,.ts,.tsx src\"\n  },\n","language":"json"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"scripts"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":": "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"dev"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"eslint --ext .js,.jsx,.vue,.ts,.tsx src && vite"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"build"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"vue-tsc --noEmit && vite build"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"serve"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"vite preview"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"lint"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"eslint --ext .js,.jsx,.vue,.ts,.tsx src"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":","}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"贴一下我自己的"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".eslintrc.js"}]}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"module.exports = {\n  root: true,\n  env: {\n    node: true,\n  },\n  extends: ['plugin:vue/vue3-essential', 'eslint:recommended', '@vue/typescript/recommended'],\n  parserOptions: {\n    ecmaVersion: 2020,\n  },\n  rules: {\n    // disable the rule for all files\n    '@typescript-eslint/explicit-module-boundary-types': 'off',\n  },\n  overrides: [\n    {\n      // enable the rule specifically for TypeScript files\n      files: ['*.js', '*.ts'],\n      rules: {\n        '@typescript-eslint/explicit-module-boundary-types': 'warn',\n      },\n    },\n  ],\n};\n\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"module.exports"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"root"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"true"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"env"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"node"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FF9CAC"}},"children":[{"type":"text","value":"true"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"extends"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ["}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"plugin:vue/vue3-essential"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"eslint:recommended"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"@vue/typescript/recommended"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"parserOptions"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"ecmaVersion"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"2020"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"rules"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// disable the rule for all files"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"@typescript-eslint/explicit-module-boundary-types"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"off"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"overrides"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ["}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// enable the rule specifically for TypeScript files"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"files"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ["}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"*.js"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"*.ts"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"rules"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"@typescript-eslint/explicit-module-boundary-types"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"warn"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  ]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"};"}]}]}]}]}]}]},{"type":"element","tag":"h4","props":{"id":"提交修复"},"children":[{"type":"text","value":"提交修复"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"我们希望在代码提交之前做一次 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"lint"}]},{"type":"text","value":" 检查和修复，我们需要用到 Git Hook，在本地执行 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"git commit"}]},{"type":"text","value":" 的时候，就对所提交的代码进行 ESLint 检测和修复（即执行 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"eslint --fix"}]},{"type":"text","value":"），如果这些代码没通过 ESLint 规则校验，则禁止提交。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"这里需要使用到两个工具:"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/typicode/husky","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"husky"}]},{"type":"text","value":" —— Git Hook 工具，可以设置在 git 各个阶段（"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"pre-commit"}]},{"type":"text","value":"、"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"commit-msg"}]},{"type":"text","value":"、"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"pre-push"}]},{"type":"text","value":" 等）触发我们的命令。"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/okonet/lint-staged","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"lint-staged"}]},{"type":"text","value":" —— 在 git 暂存的文件上运行 linters。"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"第一步，安装插件并初始化一个 husky 配置，这一步会在根目录下生成 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".husky "}]},{"type":"text","value":"目录"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"shell","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"npx husky-init && yarn\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"npx husky-init "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"&&"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" yarn"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"第二步，修改 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"pre-commit"}]},{"type":"text","value":"规则，但缺点是这一步会扫描所有文件"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"bash","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"##!/bin/sh\n. \"$(dirname \"$0\")/_/husky.sh\"\n\neslint --fix ./src --ext .vue,.js,.ts\n","language":"bash"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"##!/bin/sh"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\"$("}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"dirname "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\"$"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"0"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/_/husky.sh"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"eslint --fix ./src --ext .vue,.js,.ts"}]}]}]}]}]}]},{"type":"element","tag":"Image","props":{"alt":"image-20210723150047244","src":"https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/e8519380eda14665b37258d8ad969c2a~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"第三步，安装并配置"},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"lint-staged"}]}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"shell","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"yarn add lint-staged\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"yarn add lint-staged"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"然后在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"package.json"}]},{"type":"text","value":"里增加 lint-staged 配置项"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"json","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"  \"lint-staged\": {\n    \"*.{vue,js,ts,tsx,jsx}\": \"eslint --fix\"\n  }\n","language":"json"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"lint-staged"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":": "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"*.{vue,js,ts,tsx,jsx}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"eslint --fix"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"验证效果，我写了一段错误代码在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"demo.ts"}]},{"type":"text","value":"，然后去提交代码，husky 和 lint-staged 就起了关键作用，如果是 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"warning"}]},{"type":"text","value":" 级别可以正确修复，如果是 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"error"}]},{"type":"text","value":" 就会在控制台打印出错误日志"}]},{"type":"element","tag":"Image","props":{"alt":"image-20210723151610043","src":"https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/e43a63987ee54443b9d7f0db93c4d51a~tplv-k3u1fbpfcp-zoom-1.image"},"children":[]},{"type":"element","tag":"h3","props":{"id":"单元测试"},"children":[{"type":"text","value":"单元测试"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"单元测试是项目开发中一个非常重要的环节，完整的测试能为代码和业务提供质量保证，减少 Bug 的出现"}]},{"type":"element","tag":"h4","props":{"id":"安装并配置核心依赖"},"children":[{"type":"text","value":"安装并配置核心依赖"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/vuejs/vue-test-utils-next","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"vue-test-utils"}]}]},{"type":"text","value":" Vue 团队开发和维护的测试库"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/facebook/jest","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"jest"}]}]},{"type":"text","value":" 官方推荐测试库"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/vuejs/vue-jest","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"vue-jest"}]}]},{"type":"text","value":" 负责 jest  扫描 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".vue"}]},{"type":"text","value":" 和转换"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/kulshekhar/ts-jest","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"ts-jest"}]}]},{"type":"text","value":" 负责 jest 扫描 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".ts"}]},{"type":"text","value":" 和转换"}]}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"shell","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"yarn add @vue/test-utils@next jest vue-jest@next ts-jest -D    \n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"yarn add @vue/test-utils@next jest vue-jest@next ts-jest -D    "}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"添加 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"jest.config.js"}]}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"module.exports = {\n  moduleFileExtensions: ['vue', 'js', 'ts'],\n  preset: 'ts-jest',\n  testEnvironment: 'jsdom',\n  transform: {\n    '^.+\\\\.vue$': 'vue-jest', // vue 文件用 vue-jest 转换\n    '^.+\\\\.ts$': 'ts-jest', // ts 文件用 ts-jest 转换\n  },\n  // 匹配 __tests__ 目录下的 .js/.ts 文件 或其他目录下的 xx.test.js/ts xx.spec.js/ts\n  testRegex: '(/__tests__/.*|(\\\\.|/)(test|spec))\\\\.(ts)$',\n};\n\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"module.exports"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"moduleFileExtensions"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ["}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"js"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"ts"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"preset"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"ts-jest"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"testEnvironment"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"jsdom"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"transform"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"^.+"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\\"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":".vue$"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"vue-jest"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// vue 文件用 vue-jest 转换"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"^.+"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\\"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":".ts$"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"ts-jest"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// ts 文件用 ts-jest 转换"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// 匹配 __tests__ 目录下的 .js/.ts 文件 或其他目录下的 xx.test.js/ts xx.spec.js/ts"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"testRegex"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"(/__tests__/.*|("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\\"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":".|/)(test|spec))"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\\\"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":".(ts)$"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"};"}]}]}]}]}]}]},{"type":"element","tag":"h4","props":{"id":"集成typesjest-和-eslint-plugin-jest"},"children":[{"type":"text","value":"集成@types/jest 和 eslint-plugin-jest"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"这两个工具主要是为了解决编辑器 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"jest"}]},{"type":"text","value":" 代码提示错误和 eslint 对 jest 的支持"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"shell","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"yarn add @types/jest eslint-plugin-jest -D\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"yarn add @types/jest eslint-plugin-jest -D"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"修改 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"tsconfig.json"}]}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"json","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"{\n  \"compilerOptions\": {\n    ...\n    \"types\": [\"vite/client\", \"jest\"]\n  },\n}\n","language":"json"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"compilerOptions"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    ..."}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"types"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"["}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"vite/client"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"jest"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"]"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".eslintrc.js"}]},{"type":"text","value":" 添加 jest lint 插件 配置"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"{\n  ...\n    extends: [\n    'plugin:vue/vue3-essential',\n    'eslint:recommended',\n    '@vue/typescript/recommended',\n    'plugin:jest/recommended',\n  ],\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"..."}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"extends"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ["}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"plugin:vue/vue3-essential"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"eslint:recommended"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"@vue/typescript/recommended"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"plugin:jest/recommended"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  ]"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"h4","props":{"id":"编写单元测试"},"children":[{"type":"text","value":"编写单元测试"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"创建 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"tests"}]},{"type":"text","value":" 目录，然后创建 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"xx.spec.ts"}]},{"type":"text","value":" 文件编写单元测试，然后测试"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"typescript","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"// Axios.spec.ts\nimport { mount } from '@vue/test-utils';\nimport Axios from '../src/views/Axios.vue';\n\ndescribe('Axios.vue', () => {\n  it('renders', () => {\n    const wrapper = mount(Axios);\n    expect(wrapper.html()).toContain('Vite2.x + Vue3.x + TypeScript Starter');\n  });\n});\n\n","language":"typescript"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// Axios.spec.ts"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"mount"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"@vue/test-utils"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" Axios "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"../src/views/Axios.vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"describe"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"Axios.vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"it"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"renders"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"wrapper"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"mount"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"Axios"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"expect"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"wrapper"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"html"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"())"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"toContain"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"Vite2.x + Vue3.x + TypeScript Starter"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]}]}]}]}]},{"type":"element","tag":"blockquote","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"建议打包时执行前置单元测试，如果希望在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"push"}]},{"type":"text","value":" 代码之前执行单元测试，只需要在 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".husky"}]},{"type":"text","value":" 目录下创建 "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"pre-push"}]},{"type":"text","value":"脚本 ，然后添加对应测试命令即可。"}]}]},{"type":"element","tag":"h2","props":{"id":"小结"},"children":[{"type":"text","value":"小结"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"至此，一个综合性 Vue3.x 项目就搭建完成，总结下该工程的能力"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"编程语言："},{"type":"element","tag":"a","props":{"href":"https://www.typescriptlang.org/zh/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"TypeScript"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"构建工具："},{"type":"element","tag":"a","props":{"href":"https://cn.vitejs./dev/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Vite 2.x"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"前端框架："},{"type":"element","tag":"a","props":{"href":"https://v3.cn.vuejs.org/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Vue 3.x"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"路由工具："},{"type":"element","tag":"a","props":{"href":"https://next.router.vuejs.org/zh/index.html","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Vue Router 4.x"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"状态管理："},{"type":"element","tag":"a","props":{"href":"https://pinia.esm.dev/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Pinia"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"CSS 预编译："},{"type":"element","tag":"a","props":{"href":"https://stylus-lang.com/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Stylus"}]},{"type":"text","value":" / "},{"type":"element","tag":"a","props":{"href":"https://sass.bootcss.com/documentation","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Sass"}]},{"type":"text","value":" / "},{"type":"element","tag":"a","props":{"href":"http://lesscss.cn/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Less"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"HTTP 工具："},{"type":"element","tag":"a","props":{"href":"https://axios-http.com/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Axios"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Git Hook 工具："},{"type":"element","tag":"a","props":{"href":"https://typicode.github.io/husky/##/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"husky"}]},{"type":"text","value":" + "},{"type":"element","tag":"a","props":{"href":"https://github.com/okonet/lint-staged","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"lint-staged"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"代码规范："},{"type":"element","tag":"a","props":{"href":"http://editorconfig.org/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"EditorConfig"}]},{"type":"text","value":" + "},{"type":"element","tag":"a","props":{"href":"https://prettier.io/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Prettier"}]},{"type":"text","value":" + "},{"type":"element","tag":"a","props":{"href":"https://eslint.org/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"ESLint"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"单元测试："},{"type":"element","tag":"a","props":{"href":"https://next.vue-test-utils.vuejs.org/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"vue-test-utils"}]},{"type":"text","value":" + "},{"type":"element","tag":"a","props":{"href":"https://jestjs.io/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"jest"}]},{"type":"text","value":" + "},{"type":"element","tag":"a","props":{"href":"https://github.com/vuejs/vue-jest","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"vue-jest"}]},{"type":"text","value":" + "},{"type":"element","tag":"a","props":{"href":"https://kulshekhar.github.io/ts-jest/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"ts-jest"}]}]}]},{"type":"element","tag":"blockquote","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"在线预览该工程："},{"type":"element","tag":"a","props":{"href":"https://251205668.github.io/vite-vue3-sfc-template/##/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"vite-vue3-sfc-template"}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"为此我还准备了这些常用模板"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Vue2.x + vite 模板"},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"TSX + decorator能力："},{"type":"element","tag":"a","props":{"href":"https://github.com/251205668/vite-vue2-start/tree/tsx-decorator","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"vite-vue2-tsx-start"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"SFC + decorator能力："},{"type":"element","tag":"a","props":{"href":"https://github.com/251205668/vite-vue2-start","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"vite-vue2-start"}]}]}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Vue3.x + vite 模板"},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"TSX + composition-api能力："},{"type":"element","tag":"a","props":{"href":"https://github.com/251205668/vite-vue3-start","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"vite-vue3-start"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"SFC + composition-api能力："},{"type":"element","tag":"a","props":{"href":"https://github.com/251205668/vite-vue3-sfc-template","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"vite-vue3-sfc-template"}]}]}]}]}]}]}],"toc":{"title":"","searchDepth":2,"depth":2,"links":[{"id":"vite-概要介绍","depth":2,"text":"Vite 概要介绍","children":[{"id":"什么是-vite","depth":3,"text":"什么是 Vite"},{"id":"vite-和-webpack-对比","depth":3,"text":"Vite 和 webpack 对比"},{"id":"vite-带来的收益是什么","depth":3,"text":"Vite 带来的收益是什么"}]},{"id":"vite-基础应用","depth":2,"text":"Vite 基础应用","children":[{"id":"官方脚手架安装模板安装","depth":3,"text":"官方脚手架安装、模板安装"},{"id":"vite-中使用-typescript","depth":3,"text":"Vite 中使用 Typescript"},{"id":"vite-中使用-css","depth":3,"text":"Vite 中使用 CSS"},{"id":"vite-集成-jsx-和-tsx","depth":3,"text":"Vite 集成 JSX 和 TSX"},{"id":"viteconfigts-常用配置","depth":3,"text":"Vite.config.ts 常用配置"},{"id":"其他选项","depth":3,"text":"其他选项"},{"id":"webpack-进军-vite","depth":3,"text":"webpack 进军 vite"}]},{"id":"vite-常用插件","depth":2,"text":"Vite 常用插件","children":[{"id":"vitejsplugin-vue","depth":3,"text":"@vitejs/plugin-vue"},{"id":"vitejsplugin-vue-jsx","depth":3,"text":"@vitejs/plugin-vue-jsx"},{"id":"vitejsplugin-legacy","depth":3,"text":"@vitejs/plugin-legacy"},{"id":"vitejsvite-plugin-vue2","depth":3,"text":"@vitejs/vite-plugin-vue2"},{"id":"vite-plugin-components","depth":3,"text":"@vite-plugin-components"}]},{"id":"配合-vue3x-搭建工程化项目","depth":2,"text":"配合 Vue3.x 搭建工程化项目","children":[{"id":"搭建基础工程","depth":3,"text":"搭建基础工程"},{"id":"简单修改-vite-配置","depth":3,"text":"简单修改 vite 配置"},{"id":"整理目录结构","depth":3,"text":"整理目录结构"},{"id":"整合部分工具","depth":3,"text":"整合部分工具"},{"id":"代码规范","depth":3,"text":"代码规范"},{"id":"单元测试","depth":3,"text":"单元测试"}]},{"id":"小结","depth":2,"text":"小结"}]}},"_type":"markdown","_id":"content:posts:vite migration plan.md","_source":"content","_file":"posts/vite migration plan.md","_extension":"md","storageMeta":{"atime":"2023-06-16T10:26:05.626Z","mtime":"2023-06-16T10:26:05.626Z","size":42907},"readingMins":5,"path":"/blog/vite-migration-plan","renderer":"post","schemaOrg":{"modifiedAt":"2023-06-16T10:26:05.626Z"},"modifiedAt":"2023-06-16T10:26:05.626Z"},{"_path":"/posts/vue-automatic-component-imports","_draft":false,"_partial":false,"_empty":false,"title":"Building a Vue Auto Component Importer - A Better Dev Experience","description":"Components magically being imported into your app is the latest developer experience trend in Vue. Why does it exist and how does it work?","excerpt":"Having component folders auto-magically imported into your app is the latest craze. How does it work and is it good?","publishedAt":"2020-12-22","tags":["webpack","vue"],"body":{"type":"root","children":[{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"toc","props":{},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"When first learning Vue, you are taught you need to import and add components to "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"components"}]},{"type":"text","value":" in the script block."}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"vue","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"<script>\nimport HelloWorld from '@/components/HelloWorld.vue'\nexport default {\n  components: {\n    HelloWorld\n  }\n}\n</script>\n\n<template>\n  <HelloWorld />\n</template>\n","language":"vue"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" HelloWorld "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"@/components/HelloWorld.vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"components"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    HelloWorld"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"HelloWorld"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" />"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"However, there's been a recent trend to \"upgrade\" the Vue developer experience (DX), having components magically import themselves\nat compile-time."}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"vue","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"<template>\n  <HelloWorld />\n</template>\n","language":"vue"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"HelloWorld"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" />"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"In the wild, you can find auto component imports in most popular Vue frameworks, as part of the core or a plugin."}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/nuxt/components","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Nuxt Components"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/vuetifyjs/vuetify-loader","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Vuetify"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/segunadebayo/chakra-ui","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Chakra"}]}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/harlan-zw/vue-cli-plugin-import-components","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Vue CLI"}]},{"type":"text","value":" (built by me)"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/antfu/vite-plugin-components","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Vite"}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"This article will look at: why automatic component imports exist, how you can easily build our own auto component importer using\na Webpack loader and what the performance cost of using them has on your app."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Finally, we'll look at some other compile-time DX upgrades that are possible."}]},{"type":"element","tag":"h2","props":{"id":"why-automatic-component-imports"},"children":[{"type":"text","value":"Why Automatic Component Imports?"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"why"}]},{"type":"text","value":" that comes first to my mind, is the developer experience is great. No more confusion or typos on import paths,\nrefactoring becomes easier and there's less code overall."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The unintuitive but equally great advantage is found in the problem that this feature first solved."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The UI framework "},{"type":"element","tag":"a","props":{"href":"https://vuetifyjs.com/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Vuetify"}]},{"type":"text","value":" is a huge library of over 80 components, coming in at "},{"type":"element","tag":"a","props":{"href":"https://cdnjs.cloudflare.com/ajax/libs/vuetify/2.3.17/vuetify.js","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"99.4KB"}]},{"type":"text","value":"\nfor their scripts. As far as I know, they were the first to introduce automatic component imports."}]},{"type":"element","tag":"h3","props":{"id":"problem-ui-framework-bloat"},"children":[{"type":"text","value":"Problem: UI Framework Bloat"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"One of the complaints you'll hear about using a UI framework over something simple like "},{"type":"element","tag":"a","props":{"href":"https://tailwindcss.com/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"TailwindCSS"}]},{"type":"text","value":",\nis the bloat it will add to your app."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"This is a valid concern. It's unlikely your application is going to need half the components that a UI framework has to offer. Forcing\nbrowsers to download code that will never run, dead code, is not ideal."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Additionally, this component bloat can make import paths harder to work with and further scope for issues to pop up."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"So, how do Vuetify and other UI frameworks overcome their inherent bloat?"}]},{"type":"element","tag":"h3","props":{"id":"solution-webpack-optimisations"},"children":[{"type":"text","value":"Solution: webpack Optimisations"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"As is the way, webpack is here to magically solve our problems with "},{"type":"element","tag":"a","props":{"href":"https://webpack.js.org/guides/tree-shaking/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"tree shaking"}]},{"type":"text","value":" and "},{"type":"element","tag":"a","props":{"href":"https://webpack.js.org/guides/code-splitting/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"code splitting"}]},{"type":"text","value":" optimisations."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"If tree shaking is new to you, you can think of it as an optimisation to remove code that isn't explicitly used. Banishing\n'dead' code to the shadow realm."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The tree shaking optimisation requires ES2015 module syntax, (i.e. "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"import"}]},{"type":"text","value":" and "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"export"}]},{"type":"text","value":") and a production build. The code can't be compiled\nto CommonJS modules (i.e. "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"require"}]},{"type":"text","value":") for it to work."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"So how does all this relate to automatic component imports?"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"With Vuetify handling the imports of your components ("},{"type":"element","tag":"em","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://vuetifyjs.com/en/features/treeshaking/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"à la carte"}]}]},{"type":"text","value":" as they call it), they\ncan ensure webpack optimisations are running out of the box for your app with their component library."}]},{"type":"element","tag":"blockquote","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The A la carte system enables you to pick and choose which components to import, drastically lowering your build size."}]}]},{"type":"element","tag":"blockquote","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"This will also make code-splitting more effective, as webpack will only load the components required for that chunk to be displayed."}]}]},{"type":"element","tag":"h2","props":{"id":"fundamental-how-does-webpack-load-vue-files"},"children":[{"type":"text","value":"Fundamental: How Does webpack Load Vue Files?"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Before we jump into building our own automatic component importer, we'll need to have a basic understanding of how webpack loads Vue files."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"When you request a resource (such as a file) in webpack, it pushes the request through a pipeline of webpack loaders to resolve the output. A webpack loader is a piece of code which will transform a resource from one thing into another, it has an "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"input"}]},{"type":"text","value":" and "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"output"}]},{"type":"text","value":"."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"For example, the "},{"type":"element","tag":"a","props":{"href":"https://v4.webpack.js.org/loaders/raw-loader/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"raw-loader"}]},{"type":"text","value":" will read a file and give you the string contents.\nThe "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"input"}]},{"type":"text","value":" is a path to a file in your filesystem, the "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"output"}]},{"type":"text","value":" is the string contents of the file."}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"import txt from 'raw-loader!./hello.txt'\n// txt=HelloWorld\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" txt "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"raw-loader!./hello.txt"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// txt=HelloWorld"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vue-loader"}]},{"type":"text","value":" is the loader for "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":".vue"}]},{"type":"text","value":" files. The loader compiles and bundles your component Single File Component (SFC) into code\nthat the browser can understand and run."}]},{"type":"element","tag":"h3","props":{"id":"vue-loader-in-action"},"children":[{"type":"text","value":"Vue Loader in Action"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Let's take a look at an example of input and output from the vue-loader."}]},{"type":"element","tag":"h4","props":{"id":"input-appvue"},"children":[{"type":"text","value":"Input: App.vue"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"This is the default entry file for Vue CLI with Vue 3."}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"vue","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"<script>\nimport HelloWorld from './components/HelloWorld.vue'\n\nexport default {\n  name: 'App',\n  components: {\n    HelloWorld\n  }\n}\n</script>\n\n<template>\n  <img alt=\"Vue logo\" src=\"./assets/logo.png\">\n  <HelloWorld msg=\"Welcome to Your Vue.js App\" />\n</template>\n\n<style>\n#app {\n  font-family: Avenir, Helvetica, Arial, sans-serif;\n  -webkit-font-smoothing: antialiased;\n  -moz-osx-font-smoothing: grayscale;\n  text-align: center;\n  color: #2c3e50;\n  margin-top: 60px;\n}\n</style>\n","language":"vue"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" HelloWorld "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"./components/HelloWorld.vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"name"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"App"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"components"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    HelloWorld"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"img"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"alt"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"Vue logo"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"src"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"./assets/logo.png"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"HelloWorld"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"msg"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"Welcome to Your Vue.js App"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" />"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"style"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"app"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"font-family"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" Avenir"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" Helvetica"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" Arial"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" sans-serif"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"-webkit-font-smoothing"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" antialiased"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"-moz-osx-font-smoothing"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" grayscale"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"text-align"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" center"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"color"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"2c3e50"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"margin-top"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"60px"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"style"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]}]}]}]}]},{"type":"element","tag":"h4","props":{"id":"output-appvue"},"children":[{"type":"text","value":"Output: App.vue"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Internally, the loader parses this code using the compiler, getting an SFC descriptor object that is used to create the\nfinal string output of the loader."}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"import { render } from './App.vue?vue&type=template&id=7ba5bd90'\nimport script from './App.vue?vue&type=script&lang=js'\n\nimport './App.vue?vue&type=style&index=0&id=7ba5bd90&lang=css'\nexport * from './App.vue?vue&type=script&lang=js'\nscript.render = render\nscript.__file = 'src/App.vue'\n\nexport default script\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"render"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"./App.vue?vue&type=template&id=7ba5bd90"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" script "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"./App.vue?vue&type=script&lang=js"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"./App.vue?vue&type=style&index=0&id=7ba5bd90&lang=css"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"*"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"from"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"./App.vue?vue&type=script&lang=js"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"render "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" render"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"__file "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"src/App.vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" script"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Note: I've removed the Hot Module Reloading (HMR) code for simplicity here."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The output of the loader isn't that important to understand, just know that the vue-loader has an in and out function. The output\nis usually parsed to another loader such as "},{"type":"element","tag":"a","props":{"href":"https://github.com/babel/babel-loader","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"babel-loader"}]},{"type":"text","value":" before being chunked."}]},{"type":"element","tag":"h2","props":{"id":"building-an-automatic-component-importer"},"children":[{"type":"text","value":"Building an Automatic Component Importer"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"If you have some spare time, I'd encourage you to join along. You can use "},{"type":"element","tag":"a","props":{"href":"https://cli.vuejs.org/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Vue CLI"}]},{"type":"text","value":" with the Vue 3 preset."}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"shell","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"vue create auto-component-importer -p __default_vue_3__\n","language":"shell"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"vue create auto-component-importer -p __default_vue_3__"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"To begin, let's remove the manual import from the entry SFC, like so:"}]},{"type":"element","tag":"h3","props":{"id":"new-appvue"},"children":[{"type":"text","value":"New App.vue"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"vue","class":"code-block code-block--with-filename"},"children":[{"type":"element","tag":"span","props":{},"children":[{"type":"text","value":"App.vue"}]},{"type":"element","tag":"code","props":{"code":"<script>\nexport default {\n  name: 'App',\n}\n</script>\n\n<template>\n  <img alt=\"Vue logo\" src=\"./assets/logo.png\">\n  <HelloWorld msg=\"Welcome to Your Vue.js App\" />\n</template>\n\n<style>\n#app {\n  font-family: Avenir, Helvetica, Arial, sans-serif;\n  -webkit-font-smoothing: antialiased;\n  -moz-osx-font-smoothing: grayscale;\n  text-align: center;\n  color: #2c3e50;\n  margin-top: 60px;\n}\n</style>\n","filename":"App.vue","language":"vue"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"name"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"App"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"img"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"alt"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"Vue logo"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"src"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"./assets/logo.png"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"HelloWorld"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"msg"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"Welcome to Your Vue.js App"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" />"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"style"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"app"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"font-family"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" Avenir"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" Helvetica"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" Arial"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" sans-serif"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"-webkit-font-smoothing"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" antialiased"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#FFCB6B"}},"children":[{"type":"text","value":"-moz-osx-font-smoothing"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" grayscale"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"text-align"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" center"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"color"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"#"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"2c3e50"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#B2CCD6"}},"children":[{"type":"text","value":"margin-top"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"60px"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":";"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"style"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"When we load our "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"App.vue"}]},{"type":"text","value":", the "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"HelloWorld"}]},{"type":"text","value":" doesn't work, as expected. Our goal is to get it to work without touching the Vue code."}]},{"type":"element","tag":"h3","props":{"id":"step-1-modify-the-webpack-configuration"},"children":[{"type":"text","value":"Step 1. Modify the webpack Configuration"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"We need to make sure the loader we'll be making is going to run after the vue-loader."}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"module.exports = {\n  chainWebpack: (config) => {\n    config.module\n      .rules\n      .get('vue')\n      .use('components')\n      .loader(require.resolve('./imports-loader'))\n      .before('vue-loader')\n      .end()\n  }\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"module.exports"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"chainWebpack"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"config"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"config"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"module"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"rules"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"get"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"use"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"components"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"loader"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"require"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"resolve"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"./imports-loader"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"))"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"before"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"vue-loader"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"end"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"()"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"If you'd like to see the raw webpack config example, open the below."}]},{"type":"element","tag":"details","props":{},"children":[{"type":"text","value":"\n  "},{"type":"element","tag":"summary","props":{},"children":[{"type":"text","value":"webpack.config.js example"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"module.exports = {\n  // ...\n  module: {\n    rules: [\n      {\n        test: /\\.vue$/,\n        loader: 'vue-loader'\n      }\n    ]\n  }\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"module.exports"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// ..."}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"module"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"rules"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ["}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"test"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"/"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\."}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"$"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"/"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"loader"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"vue-loader"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    ]"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Knowing that webpack loaders are loaded from bottom to top, we would modify the configuration as so:"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"module.exports = {\n  // ...\n  module: {\n    rules: [\n      {\n        test: /\\.vue$/,\n        use: [\n          {\n            loader: require.resolve('./imports-loader'),\n          },\n          {\n            loader: 'vue-loader',\n          }\n        ]\n      },\n    ]\n  }\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"module.exports"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// ..."}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"module"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"rules"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ["}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"test"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"/"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\."}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"$"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"/"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"use"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ["}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"          "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"            "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"loader"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" require"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"resolve"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"./imports-loader"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"          "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"          "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"            "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"loader"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"vue-loader"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"          "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"        ]"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"},"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    ]"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"tip","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Normally a webpack would handle this configuration changing for you."}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Now we create the loader called "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"imports-loader.js"}]},{"type":"text","value":" in your apps root directory. We're going to make sure we only run it for the virtual SFC module."}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"module.exports = function loader(source) {\n  // only run for the virtual SFC\n  if (this.resourceQuery)\n    return source\n\n  console.log(source)\n  return source\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"module.exports"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"loader"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"source"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// only run for the virtual SFC"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"resourceQuery"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"source"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"console"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"log"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"source"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"source"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"source"}]},{"type":"text","value":" variable is the output of the vue-loader, the "},{"type":"element","tag":"a","props":{"href":"#output-app-vue"},"children":[{"type":"text","value":"Output: App.vue"}]},{"type":"text","value":"."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Here we can now change anything about how our components work by modifying the vue-loader output."}]},{"type":"element","tag":"h3","props":{"id":"step-2-dumb-compile-time-import"},"children":[{"type":"text","value":"Step 2. Dumb Compile-Time Import"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"As a proof of concept, let's try to import the "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"HelloWorld.vue"}]},{"type":"text","value":" component so our "},{"type":"element","tag":"a","props":{"href":"#new-app-vue"},"children":[{"type":"text","value":"New App.vue"}]},{"type":"text","value":" works."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"At this stage, we can just append the import code on to the "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"source"}]},{"type":"text","value":"."}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"module.exports = function loader(source) {\n  // only run for the virtual SFC\n  if (this.resourceQuery)\n    return source\n\n  return `${source}\nimport HelloWorld from \"@/components/HelloWorld.vue\"\nscript.components = Object.assign({ HelloWorld }, script.components)\n`\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"module.exports"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"loader"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"source"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// only run for the virtual SFC"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"resourceQuery"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"source"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"`${"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"source"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"import HelloWorld from \"@/components/HelloWorld.vue\""}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"script.components = Object.assign({ HelloWorld }, script.components)"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"`"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Your "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"App.vue"}]},{"type":"text","value":" now knows what the HelloWorld component is and works. Try it yourself."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Note: This is a "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"dumb"}]},{"type":"text","value":" solution, as it will be modifying "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"HelloWorld.vue"}]},{"type":"text","value":" to also import itself."}]},{"type":"element","tag":"h3","props":{"id":"step-3-making-it-smart"},"children":[{"type":"text","value":"Step 3. Making it smart"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"A smarter solution would give us the ability to add components to our component folder and use them straight away without\nany imports."}]},{"type":"element","tag":"h4","props":{"id":"a-scan-components"},"children":[{"type":"text","value":"a. Scan components"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The first step in making it smarter is we need to create a map of the components files we want to automatically import."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"We recursively iterate over the components folder and do some mapping."}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"const base = './src/components/'\nconst fileComponents = (await globby('*.vue', { cwd: base })).map((c) => {\n  const name = path.parse(c).name\n  const shortPath = path.resolve(base).replace(path.resolve('./src'), '@')\n  return {\n    name,\n    import: `import ${name} from \"${shortPath}/${c}\"`\n  }\n})\n// [ { name: 'HelloWorld', import: 'import HelloWorld from \"@/components/HelloWorld.vue\"' } ]\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" base "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"./src/components/"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" fileComponents "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"await"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"globby"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"*.vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"cwd"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" base "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"))"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"map"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"c"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"name"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"parse"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"c"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"name"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"shortPath"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"resolve"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"base"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"replace"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"resolve"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"./src"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"@"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"name"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"`"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"import "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"${"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"name"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":" from \""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"${"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"shortPath"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"${"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"c"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"`"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// [ { name: 'HelloWorld', import: 'import HelloWorld from \"@/components/HelloWorld.vue\"' } ]"}]}]}]}]}]}]},{"type":"element","tag":"h4","props":{"id":"b-find-the-template-tags"},"children":[{"type":"text","value":"b. Find the template tags"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"To understand what components are being used, we need to have our new loader to compile the SFC "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"<template>"}]},{"type":"text","value":" blocks."}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"const compiler = require('@vue/compiler-sfc')\nconst parsed = compiler.parse(fs.readFileSync(`${this.context}/${path.basename(this.resourcePath)}`, 'utf8')).descriptor\nconst template = compiler.compileTemplate({\n  id: 'tmp',\n  source: parsed.template.content,\n  filename: this.resourcePath,\n})\nconst componentTags = template.ast.components\n// [ 'HelloWorld' ]\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" compiler "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"require"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"@vue/compiler-sfc"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" parsed "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" compiler"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"parse"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"(fs"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"readFileSync"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"`${"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"context"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"${"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"basename"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"resourcePath)"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}`"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"utf8"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"))"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"descriptor"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" template "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" compiler"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"compileTemplate"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"id"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"tmp"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"source"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" parsed"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"content"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"filename"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"resourcePath"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" componentTags "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"ast"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"components"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// [ 'HelloWorld' ]"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Note: For simplicity, we're using Vue 3's compiler. The above won't work for Vue 2."}]},{"type":"element","tag":"h4","props":{"id":"c-matchmaking"},"children":[{"type":"text","value":"c. Matchmaking"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"With our freshly compiled template, we need to match the components we found in our template with the mapped component files\nfrom "},{"type":"element","tag":"a","props":{"href":"#a-scan-components"},"children":[{"type":"text","value":"a. Scan Components"}]},{"type":"text","value":"."}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block code-block--with-filename"},"children":[{"type":"element","tag":"span","props":{},"children":[{"type":"text","value":"c. Match making"}]},{"type":"element","tag":"code","props":{"code":"const matches = []\ncomponentTags.forEach(tag => matches.push(first(filter(fileComponents, c => c.name === tag))))\n// [ { name: 'HelloWorld', import: 'import HelloWorld from \"@/components/HelloWorld.vue\"' } ]\n","filename":"c. Match making","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" matches "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" []"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"componentTags"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"forEach"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"(tag "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" matches"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"push"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"first"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"filter"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"(fileComponents"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" c "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" c"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"name "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"==="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" tag))))"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// [ { name: 'HelloWorld', import: 'import HelloWorld from \"@/components/HelloWorld.vue\"' } ]"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"If you wanted to match non-PascalCase names, you would modify this matcher function."}]},{"type":"element","tag":"h4","props":{"id":"d-insert-the-new-dynamic-imports"},"children":[{"type":"text","value":"d. Insert the new dynamic imports"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The final piece of the puzzle is appending the list of matched components and inserting the import line and assigning\nthe components."}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"if (!matches.length)\n  return source\n\nconst newContent = `\n${matches.map(c => c.import).join('\\n')}\nscript.components = Object.assign({ ${matches.map(c => c.name).join(', ')} }, script.components);\n`\nconst hotReload = source.indexOf('/* hot reload */')\nif (hotReload > -1)\n  source = `${source.slice(0, hotReload) + newContent}\\n\\n${source.slice(hotReload)}`\nelse\n  source += `\\n\\n${newContent}`\n\nreturn source\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"!"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"matches"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"length)"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" source"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" newContent "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"`"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"${"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"matches"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"map"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"(c "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" c"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"import)"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"join"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"script.components = Object.assign({ "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"${"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"matches"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"map"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"(c "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" c"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"name)"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"join"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":", "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":" }, script.components);"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"`"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" hotReload "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" source"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"indexOf"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/* hot reload */"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" (hotReload "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"-"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"1"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  source "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"`${"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"source"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"slice"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"0"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" hotReload) "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"+"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" newContent"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"${"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"source"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"slice"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"(hotReload)"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}`"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"else"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  source "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"+="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"`"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"${"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"newContent"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}`"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" source"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"We need to insert the new content before the HMR code if available, otherwise we need to restart our app to find\nnew components."}]},{"type":"element","tag":"h3","props":{"id":"putting-it-all-together"},"children":[{"type":"text","value":"Putting it all together"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Below is the full "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"imports-loader.js"}]},{"type":"text","value":" for reference. This loader should "},{"type":"element","tag":"em","props":{},"children":[{"type":"text","value":"just work"}]},{"type":"text","value":". Create\na new component and then use it straight away, make sure you use PascalCase."}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"const fs = require('fs')\nconst path = require('path')\nconst globby = require('globby')\nconst first = require('lodash/first')\nconst filter = require('lodash/filter')\n\nmodule.exports = async function loader(source) {\n  // only run for the non-query requests\n  if (this.resourceQuery)\n    return source\n\n  // a. Scan components\n  const base = './src/components/'\n  const fileComponents = (await globby('*.vue', { cwd: base })).map((c) => {\n    const name = path.parse(c).name\n    const shortPath = path.resolve(base).replace(path.resolve('./src'), '@')\n    return {\n      name,\n      import: `import ${name} from \"${shortPath}/${c}\"`\n    }\n  })\n\n  // b. Find the template tags\n  const compiler = require('@vue/compiler-sfc')\n  const parsed = compiler.parse(fs.readFileSync(`${this.context}/${path.basename(this.resourcePath)}`, 'utf8')).descriptor\n  const template = compiler.compileTemplate({\n    id: 'na',\n    source: parsed.template.content,\n    filename: this.resourcePath,\n  })\n  const componentTags = template.ast.components\n\n  // c. Match making\n  const matches = []\n  componentTags.forEach(tag => matches.push(first(filter(fileComponents, c => c.name === tag))))\n\n  // d. Insert the new dynamic imports\n  if (!matches.length)\n    return source\n\n  const newContent = `\n${matches.map(c => c.import).join('\\n')}\nscript.components = Object.assign({ ${matches.map(c => c.name).join(', ')} }, script.components);\n`\n  const hotReload = source.indexOf('/* hot reload */')\n  if (hotReload > -1)\n    source = `${source.slice(0, hotReload) + newContent}\\n\\n${source.slice(hotReload)}`\n  else\n    source += `\\n\\n${newContent}`\n\n  return source\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" fs "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"require"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"fs"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" path "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"require"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" globby "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"require"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"globby"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" first "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"require"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"lodash/first"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" filter "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"require"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"lodash/filter"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"module.exports"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"async"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"loader"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"source"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// only run for the non-query requests"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"resourceQuery"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"source"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// a. Scan components"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"base"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"./src/components/"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"fileComponents"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"await"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"globby"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"*.vue"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" cwd"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"base"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"))"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"map"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"c"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"name"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"parse"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"c"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"name"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"shortPath"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"resolve"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"base"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"replace"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"resolve"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"./src"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"@"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"name"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      import"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"`"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"import "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"${"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"name"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":" from \""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"${"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"shortPath"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"${"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"c"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"`"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// b. Find the template tags"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"compiler"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"require"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"@vue/compiler-sfc"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"parsed"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"compiler"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"parse"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"fs"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"readFileSync"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"`${"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"context"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"${"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"path"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"basename"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"resourcePath)"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}`"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"utf8"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"))"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"descriptor"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"compiler"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"compileTemplate"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    id"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"na"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    source"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"parsed"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"content"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    filename"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"resourcePath"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"componentTags"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"ast"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"components"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// c. Match making"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"matches"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" []"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"componentTags"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"forEach"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"tag"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"matches"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"push"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"first"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"filter"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"fileComponents"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"c"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"c"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"name"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"==="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"tag"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"))))"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// d. Insert the new dynamic imports"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"!"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"matches"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"length"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"source"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"newContent"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"`"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"${"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"matches"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"map"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"(c "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" c"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"import)"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"join"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"script.components = Object.assign({ "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"${"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"matches"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"map"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"(c "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"=>"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" c"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"name)"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"join"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":", "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":" }, script.components);"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"`"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"const"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"hotReload"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"source"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"indexOf"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"/* hot reload */"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"if"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" ("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"hotReload"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"-"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"1"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":")"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"source"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"`${"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"source"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"slice"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"0"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":","}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" hotReload) "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"+"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" newContent"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"${"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"source"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"slice"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"(hotReload)"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}`"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"else"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"source"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"+="}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"`"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"\\n\\n"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"${"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"newContent"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}`"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"source"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"tip","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"There are several issues and edge cases with the above code, this is merely a proof of concept and shouldn't be used in\nproduction."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"If you're after a more complete solution you should clone the repos listed before."}]}]},{"type":"element","tag":"h2","props":{"id":"problems-with-automatic-component-imports"},"children":[{"type":"text","value":"Problems With Automatic Component Imports"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Hopefully, you now have a better understanding of how auto component importing works. While working through that rough proof of\nconcept, you may have foreseen some issues."}]},{"type":"element","tag":"h3","props":{"id":"performance-cost"},"children":[{"type":"text","value":"Performance Cost"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"For automatic component imports to provide their magic, they need to parse the SFC and compile the template at compile time. If you recall,\nwe are running our loader after the "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"vue-loader"}]},{"type":"text","value":", that means this compilation has already been completed and is happening again."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"This means that by using this feature, we are potentially "},{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"doubling our component build time"}]},{"type":"text","value":". Which affects the hot module\nreplacement speed, the web-dev-server boot-time and the production build time."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Saying that certain optimisations can and are made. Loader output can be cached with one line, so unless we change a file\nwe don't need to recompile it."}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"js","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"// ...\nmodule.exports = async function loader(source) {\n  this.cache()\n  // ...\n}\n","language":"js"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// ..."}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"module.exports"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"async"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"function"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"loader"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"("}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"source"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":")"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"this."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"cache"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"()"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#545454"}},"children":[{"type":"text","value":"// ..."}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"For Vue 3 there may be a new way to optimise this feature. I've based the proof of concept on how the existing Vue 2 plugins work."}]},{"type":"element","tag":"h3","props":{"id":"static-code-only"},"children":[{"type":"text","value":"Static code only"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"If you have a dynamic import then it's not going to work. I don't think this is a massive issue as you can\nwork around it with manual imports or using the "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"v-if"}]},{"type":"text","value":" on inline components. Consider the below\ncode:"}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"vue","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"<script>\nexport default {\n  computed: {\n    myComponent() {\n      return Math.random() * 100 > 50 ? ComponentA : ComponentB\n    }\n  }\n}\n</script>\n\n<template>\n  <component :is=\"myComponent\" />\n</template>\n","language":"vue"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"computed"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"myComponent"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"Math"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"."}]},{"type":"element","tag":"span","props":{"style":{"color":"#82AAFF"}},"children":[{"type":"text","value":"random"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"() "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"*"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"100"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F78C6C"}},"children":[{"type":"text","value":"50"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"?"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"ComponentA"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"ComponentB"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"component"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"is"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"myComponent"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" />"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"For now, the automatic import of "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"ComponentA"}]},{"type":"text","value":" and "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"ComponentB"}]},{"type":"text","value":" is not possible."}]},{"type":"element","tag":"h3","props":{"id":"stricter-component-naming"},"children":[{"type":"text","value":"Stricter component naming"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Due to the nature of mapping a file name to a component name, it sets a few requirements around how you name your components.\nIf you're following the Vue "},{"type":"element","tag":"a","props":{"href":"https://vuejs.org/v2/style-guide/#Multi-word-component-names-essential","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"style-guide"}]},{"type":"text","value":" for component naming, you shouldn't have an issue."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"If you're going to adopt automatic component imports I'd recommend the following rules:"}]},{"type":"element","tag":"ul","props":{},"children":[{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Namespace all components (i.e "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"HButtonOutline"}]},{"type":"text","value":", "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"H"}]},{"type":"text","value":" is the namespace)"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Avoid non-unique component file names"}]},{"type":"element","tag":"li","props":{},"children":[{"type":"text","value":"Use nested folders to separate scopes"}]}]},{"type":"element","tag":"h2","props":{"id":"other-compile-time-upgrades"},"children":[{"type":"text","value":"Other Compile-Time \"Upgrades\""}]},{"type":"element","tag":"h3","props":{"id":"import-directive-support"},"children":[{"type":"text","value":"Import Directive Support"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"When compiling the template, we can also see when specific directives are used.\nIf the directive is not globally registered, then we can do an automatic compile-time import of it."}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"vue","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"<script>\nexport default {\n  data() {\n    return {\n      bar: 'foo'\n    }\n  }\n}\n</script>\n\n<template>\n  <div>\n    <input v-my-directive=\"bar\">\n  </div>\n</template>\n","language":"vue"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"export"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"default"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"data"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"()"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"return"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"{"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"      bar"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":":"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"foo"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"'"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"    "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"  "}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"}"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"script"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"div"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"    <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"input"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"v-my-directive"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"bar"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  </"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"div"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"We could imagine that we could write some code which would inject the directive such as "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"import MyDirective from \"@/directives/MyDirective\""}]},{"type":"text","value":"."}]},{"type":"element","tag":"h3","props":{"id":"progressive-images"},"children":[{"type":"text","value":"Progressive Images"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"We hook into the compiling again and replace the source of our images with compile-time low-resolution versions."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"Input"}]}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"vue","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"<template>\n  <v-img src=\"@/images/my-image\" />\n</template>\n","language":"vue"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"v-img"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"src"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"@/images/my-image"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" />"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]}]}]}]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"strong","props":{},"children":[{"type":"text","value":"Output"}]}]},{"type":"element","tag":"CodeBlock","props":{"data-language":"vue","class":"code-block "},"children":[{"type":"element","tag":"code","props":{"code":"<template>\n  <v-img placeholder=\"@/images/my-image-placeholder\" src=\"@/images/my-image\" />\n</template>\n","language":"vue"},"children":[{"type":"element","tag":"pre","props":{},"children":[{"type":"element","tag":"code","props":{"__ignoreMap":""},"children":[{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"<"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":">"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"  <"}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"v-img"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"placeholder"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"@/images/my-image-placeholder"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" "}]},{"type":"element","tag":"span","props":{"style":{"color":"#C792EA"}},"children":[{"type":"text","value":"src"}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":"="}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#C3E88D"}},"children":[{"type":"text","value":"@/images/my-image"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"\""}]},{"type":"element","tag":"span","props":{"style":{"color":"#EEFFFF"}},"children":[{"type":"text","value":" />"}]}]},{"type":"element","tag":"span","props":{"class":"line"},"children":[{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":"</"}]},{"type":"element","tag":"span","props":{"style":{"color":"#F07178"}},"children":[{"type":"text","value":"template"}]},{"type":"element","tag":"span","props":{"style":{"color":"#89DDFF"}},"children":[{"type":"text","value":">"}]}]}]}]}]}]},{"type":"element","tag":"h3","props":{"id":"async-imports"},"children":[{"type":"text","value":"Async imports"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"The "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"@nuxt/components"}]},{"type":"text","value":" package does offer this functionality as opt-in through a "},{"type":"element","tag":"code-inline","props":{},"children":[{"type":"text","value":"Lazy"}]},{"type":"text","value":" prefix on the component."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"It makes use webpack's "},{"type":"element","tag":"a","props":{"href":"https://webpack.js.org/guides/lazy-loading/","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"Lazy Loading"}]},{"type":"text","value":" which bundles imports as their own dependency.\nThis is useful for if you have heavy components that aren't above the fold."}]},{"type":"element","tag":"h2","props":{"id":"conclusion"},"children":[{"type":"text","value":"Conclusion"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"Vue is already one of the most developer-friendly frontend frameworks around, with continued improvements in the dev experience\nVue will continue to flourish."}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"While these compile-time upgrades are not needed, they do make life easier. The possibilities\nwith injecting code at compile time opens up many opportunities for reducing the 'chores' that seem to follow us around\nproject to project."}]}],"toc":{"title":"","searchDepth":2,"depth":2,"links":[{"id":"why-automatic-component-imports","depth":2,"text":"Why Automatic Component Imports?","children":[{"id":"problem-ui-framework-bloat","depth":3,"text":"Problem: UI Framework Bloat"},{"id":"solution-webpack-optimisations","depth":3,"text":"Solution: webpack Optimisations"}]},{"id":"fundamental-how-does-webpack-load-vue-files","depth":2,"text":"Fundamental: How Does webpack Load Vue Files?","children":[{"id":"vue-loader-in-action","depth":3,"text":"Vue Loader in Action"}]},{"id":"building-an-automatic-component-importer","depth":2,"text":"Building an Automatic Component Importer","children":[{"id":"new-appvue","depth":3,"text":"New App.vue"},{"id":"step-1-modify-the-webpack-configuration","depth":3,"text":"Step 1. Modify the webpack Configuration"},{"id":"step-2-dumb-compile-time-import","depth":3,"text":"Step 2. Dumb Compile-Time Import"},{"id":"step-3-making-it-smart","depth":3,"text":"Step 3. Making it smart"},{"id":"putting-it-all-together","depth":3,"text":"Putting it all together"}]},{"id":"problems-with-automatic-component-imports","depth":2,"text":"Problems With Automatic Component Imports","children":[{"id":"performance-cost","depth":3,"text":"Performance Cost"},{"id":"static-code-only","depth":3,"text":"Static code only"},{"id":"stricter-component-naming","depth":3,"text":"Stricter component naming"}]},{"id":"other-compile-time-upgrades","depth":2,"text":"Other Compile-Time \"Upgrades\"","children":[{"id":"import-directive-support","depth":3,"text":"Import Directive Support"},{"id":"progressive-images","depth":3,"text":"Progressive Images"},{"id":"async-imports","depth":3,"text":"Async imports"}]},{"id":"conclusion","depth":2,"text":"Conclusion"}]}},"_type":"markdown","_id":"content:posts:vue-automatic-component-imports.md","_source":"content","_file":"posts/vue-automatic-component-imports.md","_extension":"md","storageMeta":{"atime":"2023-06-16T10:26:05.626Z","mtime":"2023-06-16T10:26:05.626Z","size":18202},"readingMins":8,"path":"/blog/vue-automatic-component-imports","renderer":"post","schemaOrg":{"modifiedAt":"2023-06-16T10:26:05.626Z"},"modifiedAt":"2023-06-16T10:26:05.626Z"},{"_path":"/posts/working-with-zustand","_draft":false,"_partial":false,"_empty":false,"title":"艺术般的字体：霞鹜文楷","description":"一款开源中文字体，基于 FONTWORKS 出品字体 Klee One 衍生","excerpt":{"type":"root","children":[{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"img","props":{"alt":"img","src":"https://cdn.nlark.com/yuque/0/2023/png/785653/1676256277829-3b169bbf-7e8a-43b6-acbb-908a06f3d436.png"},"children":[]}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"豫章故郡，洪都新府。星分"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E7%BF%BC%E5%AE%BF","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"翼"}]},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E8%BB%AB%E5%AE%BF","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"轸"}]},{"type":"text","value":"，地接"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E8%A1%A1%E5%B1%B1","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"衡"}]},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E5%BA%90%E5%B1%B1","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"庐"}]},{"type":"text","value":"。襟三江而带五湖，控蛮荆而引瓯越。物华天宝，"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E9%BE%8D%E6%B3%89%E5%8A%8D","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"龙光"}]},{"type":"text","value":"射牛斗之墟；人杰地灵，"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E5%BE%90%E7%A8%9A","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"徐孺"}]},{"type":"text","value":"下"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E9%99%B3%E8%95%83","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"陈蕃"}]},{"type":"text","value":"之榻。雄州雾列，俊彩星驰。台隍枕夷夏之交，宾主尽东南之美。都督阎公之雅望，棨戟遥临；宇文新州之懿范，襜帷暂驻。十旬休暇，胜友如云。千里逢迎，高朋满座。腾蛟起凤，孟学士之词宗；紫电青霜，"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E7%8E%8B%E5%83%A7%E8%BE%AF","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"王将军"}]},{"type":"text","value":"之武库。家君作宰，路出名区。童子何知？躬逢胜饯。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"时维九月，序属三秋。潦水尽而寒潭清，烟光凝而暮山紫。俨骖𬴂于上路，访风景于崇阿。临帝子之长洲，得仙人之旧馆。层台耸翠，上出重霄；飞阁流丹，下临无地。鹤汀凫渚，穷岛屿之萦回；桂殿兰宫，即冈峦之体势。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"披绣闼，俯雕甍。山原旷其盈视，川泽纡其骇瞩。闾阎扑地，钟鸣鼎食之家；舸舰迷津，青雀黄龙之舳。云销雨霁，彩彻区明。落霞与孤鹜齐飞["},{"type":"element","tag":"a","props":{"href":"https://zh.wikisource.org/zh-hans/%E6%BB%95%E7%8E%8B%E9%96%A3%E5%BA%8F#cite_note-3","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"3]"}]},{"type":"text","value":"，秋水共长天一色。渔舟唱晚，响穷彭蠡之滨；雁阵惊寒，声断衡阳之浦。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"遥襟甫畅，逸兴遄飞。爽籁发而清风生，纤歌凝而白云遏。睢园绿竹，气凌彭泽之樽；邺水朱华，光照临川之笔。四美具，二难并。穷睇眄于中天，极娱游于暇日。天高地迥，觉宇宙之无穷；兴尽悲来，识盈虚之有数。望长安于日下，目吴会于云间。地势极而南溟深，天柱高而北辰远。关山难越，谁悲失路之人；萍水相逢，尽是他乡之客。怀帝阍而不见，奉宣室以何年？"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"嗟乎！时运不齐，命途多舛。"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E5%86%AF%E5%94%90_(%E6%B1%89%E6%9C%9D)","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"冯唐"}]},{"type":"text","value":"易老，"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E6%9D%8E%E5%BB%A3","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"李广"}]},{"type":"text","value":"难封。屈"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E8%B3%88%E8%AA%BC","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"贾谊"}]},{"type":"text","value":"于长沙，非无圣主；窜"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E6%A2%81%E9%B4%BB","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"梁鸿"}]},{"type":"text","value":"于海曲，岂乏明时？所赖君子安贫，达人知命。老当益壮，宁移白首之心；穷且益坚，不坠青云之志。酌贪泉而觉爽，处涸辙以犹欢。北海虽赊，扶摇可接；东隅已逝，桑榆非晚。"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E5%AD%9F%E5%98%97%E5%90%9B","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"孟尝"}]},{"type":"text","value":"高洁，空馀报国之心；"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E9%98%AE%E7%B1%8D","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"阮籍"}]},{"type":"text","value":"猖狂，岂效穷途之哭？"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"勃，三尺微命，一介书生，无路请缨，等"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E7%B5%82%E8%BB%8D","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"终军"}]},{"type":"text","value":"之弱冠；有怀投笔，慕"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E5%AE%97%E6%85%A4","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"宗悫"}]},{"type":"text","value":"之长风。舍簪笏于百龄，奉晨昏于万里。非"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E9%99%B3%E9%83%A1%E8%AC%9D%E6%B0%8F","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"谢家"}]},{"type":"text","value":"之宝树，接"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E5%AD%9F%E5%AD%90","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"孟氏"}]},{"type":"text","value":"之芳邻。他日趋庭，叨陪"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E5%AD%94%E9%AF%89","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"鲤"}]},{"type":"text","value":"对；今兹捧袂，喜托龙门。"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E6%A5%8A%E5%BE%97%E6%84%8F","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"杨意"}]},{"type":"text","value":"不逢，抚凌云而自惜；"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E9%8D%BE%E5%AD%90%E6%9C%9F","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"锺期"}]},{"type":"text","value":"既遇，奏流水以何惭？"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"呜呼！胜地不常，盛筵难再。兰亭已矣，梓泽丘墟。临别赠言，幸承恩于伟饯；登高作赋，是所望于群公。敢竭鄙诚，恭疏短引。一言均赋，四韵俱成。请洒潘江，各倾陆海云尔。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"滕王高阁临江渚，佩玉鸣鸾罢歌舞。\n画栋朝飞南浦云，珠帘暮卷西山雨。\n闲云潭影日悠悠，物换星移几度秋。\n阁中帝子今何在？槛外长江空自流！"}]},{"type":"element","tag":"blockquote","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/lxgw/LxgwWenKai","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"字体开源地址"}]}]}]}]},"publishedAt":"2023-02-13","status":"published","tags":["杂记"],"body":{"type":"root","children":[{"type":"element","tag":"Image","props":{"alt":"img","src":"https://cdn.nlark.com/yuque/0/2023/png/785653/1676256277829-3b169bbf-7e8a-43b6-acbb-908a06f3d436.png"},"children":[]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"豫章故郡，洪都新府。星分"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E7%BF%BC%E5%AE%BF","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"翼"}]},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E8%BB%AB%E5%AE%BF","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"轸"}]},{"type":"text","value":"，地接"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E8%A1%A1%E5%B1%B1","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"衡"}]},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E5%BA%90%E5%B1%B1","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"庐"}]},{"type":"text","value":"。襟三江而带五湖，控蛮荆而引瓯越。物华天宝，"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E9%BE%8D%E6%B3%89%E5%8A%8D","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"龙光"}]},{"type":"text","value":"射牛斗之墟；人杰地灵，"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E5%BE%90%E7%A8%9A","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"徐孺"}]},{"type":"text","value":"下"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E9%99%B3%E8%95%83","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"陈蕃"}]},{"type":"text","value":"之榻。雄州雾列，俊彩星驰。台隍枕夷夏之交，宾主尽东南之美。都督阎公之雅望，棨戟遥临；宇文新州之懿范，襜帷暂驻。十旬休暇，胜友如云。千里逢迎，高朋满座。腾蛟起凤，孟学士之词宗；紫电青霜，"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E7%8E%8B%E5%83%A7%E8%BE%AF","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"王将军"}]},{"type":"text","value":"之武库。家君作宰，路出名区。童子何知？躬逢胜饯。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"时维九月，序属三秋。潦水尽而寒潭清，烟光凝而暮山紫。俨骖𬴂于上路，访风景于崇阿。临帝子之长洲，得仙人之旧馆。层台耸翠，上出重霄；飞阁流丹，下临无地。鹤汀凫渚，穷岛屿之萦回；桂殿兰宫，即冈峦之体势。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"披绣闼，俯雕甍。山原旷其盈视，川泽纡其骇瞩。闾阎扑地，钟鸣鼎食之家；舸舰迷津，青雀黄龙之舳。云销雨霁，彩彻区明。落霞与孤鹜齐飞["},{"type":"element","tag":"a","props":{"href":"https://zh.wikisource.org/zh-hans/%E6%BB%95%E7%8E%8B%E9%96%A3%E5%BA%8F#cite_note-3","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"3]"}]},{"type":"text","value":"，秋水共长天一色。渔舟唱晚，响穷彭蠡之滨；雁阵惊寒，声断衡阳之浦。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"遥襟甫畅，逸兴遄飞。爽籁发而清风生，纤歌凝而白云遏。睢园绿竹，气凌彭泽之樽；邺水朱华，光照临川之笔。四美具，二难并。穷睇眄于中天，极娱游于暇日。天高地迥，觉宇宙之无穷；兴尽悲来，识盈虚之有数。望长安于日下，目吴会于云间。地势极而南溟深，天柱高而北辰远。关山难越，谁悲失路之人；萍水相逢，尽是他乡之客。怀帝阍而不见，奉宣室以何年？"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"嗟乎！时运不齐，命途多舛。"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E5%86%AF%E5%94%90_(%E6%B1%89%E6%9C%9D)","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"冯唐"}]},{"type":"text","value":"易老，"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E6%9D%8E%E5%BB%A3","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"李广"}]},{"type":"text","value":"难封。屈"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E8%B3%88%E8%AA%BC","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"贾谊"}]},{"type":"text","value":"于长沙，非无圣主；窜"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E6%A2%81%E9%B4%BB","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"梁鸿"}]},{"type":"text","value":"于海曲，岂乏明时？所赖君子安贫，达人知命。老当益壮，宁移白首之心；穷且益坚，不坠青云之志。酌贪泉而觉爽，处涸辙以犹欢。北海虽赊，扶摇可接；东隅已逝，桑榆非晚。"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E5%AD%9F%E5%98%97%E5%90%9B","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"孟尝"}]},{"type":"text","value":"高洁，空馀报国之心；"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E9%98%AE%E7%B1%8D","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"阮籍"}]},{"type":"text","value":"猖狂，岂效穷途之哭？"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"勃，三尺微命，一介书生，无路请缨，等"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E7%B5%82%E8%BB%8D","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"终军"}]},{"type":"text","value":"之弱冠；有怀投笔，慕"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E5%AE%97%E6%85%A4","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"宗悫"}]},{"type":"text","value":"之长风。舍簪笏于百龄，奉晨昏于万里。非"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E9%99%B3%E9%83%A1%E8%AC%9D%E6%B0%8F","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"谢家"}]},{"type":"text","value":"之宝树，接"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E5%AD%9F%E5%AD%90","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"孟氏"}]},{"type":"text","value":"之芳邻。他日趋庭，叨陪"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E5%AD%94%E9%AF%89","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"鲤"}]},{"type":"text","value":"对；今兹捧袂，喜托龙门。"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E6%A5%8A%E5%BE%97%E6%84%8F","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"杨意"}]},{"type":"text","value":"不逢，抚凌云而自惜；"},{"type":"element","tag":"a","props":{"href":"https://zh.wikipedia.org/wiki/%E9%8D%BE%E5%AD%90%E6%9C%9F","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"锺期"}]},{"type":"text","value":"既遇，奏流水以何惭？"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"呜呼！胜地不常，盛筵难再。兰亭已矣，梓泽丘墟。临别赠言，幸承恩于伟饯；登高作赋，是所望于群公。敢竭鄙诚，恭疏短引。一言均赋，四韵俱成。请洒潘江，各倾陆海云尔。"}]},{"type":"element","tag":"p","props":{},"children":[{"type":"text","value":"滕王高阁临江渚，佩玉鸣鸾罢歌舞。\n画栋朝飞南浦云，珠帘暮卷西山雨。\n闲云潭影日悠悠，物换星移几度秋。\n阁中帝子今何在？槛外长江空自流！"}]},{"type":"element","tag":"blockquote","props":{},"children":[{"type":"element","tag":"p","props":{},"children":[{"type":"element","tag":"a","props":{"href":"https://github.com/lxgw/LxgwWenKai","rel":["nofollow","noopener","noreferrer"],"target":"_blank"},"children":[{"type":"text","value":"字体开源地址"}]}]}]}],"toc":{"title":"","searchDepth":2,"depth":2,"links":[]}},"_type":"markdown","_id":"content:posts:working-with-zustand.md","_source":"content","_file":"posts/working-with-zustand.md","_extension":"md","storageMeta":{"atime":"2023-06-16T10:26:05.626Z","mtime":"2023-06-16T10:26:05.626Z","size":4112},"readingMins":1,"path":"/blog/working-with-zustand","renderer":"post","schemaOrg":{"modifiedAt":"2023-06-16T10:26:05.626Z"},"modifiedAt":"2023-06-16T10:26:05.626Z"},{"_path":"/projects","_draft":false,"_partial":false,"body":[{"name":"Toy project","projects":[{"name":"ChatGPT-demo","description":"Minimal web UI for ChatGPT.","link":"https://github.com/anse-app/chatgpt-demo","icon":"<svg preserveAspectRatio=\"xMidYMid meet\" viewBox=\"0 0 32 32\" width=\"1em\" height=\"1em\" ><path fill=\"currentColor\" d=\"M18 10h2v2h-2zm-6 0h2v2h-2z\"/><path fill=\"currentColor\" d=\"M26 20h-5v-2h1a2.002 2.002 0 0 0 2-2v-4h2v-2h-2V8a2.002 2.002 0 0 0-2-2h-2V2h-2v4h-4V2h-2v4h-2a2.002 2.002 0 0 0-2 2v2H6v2h2v4a2.002 2.002 0 0 0 2 2h1v2H6a2.002 2.002 0 0 0-2 2v8h2v-8h20v8h2v-8a2.002 2.002 0 0 0-2-2ZM10 8h12v8H10Zm3 10h6v2h-6Z\"/></svg>"},{"name":"Anse","description":"Anse is a fully optimized UI for AI Chats.","link":"https://github.com/anse-app/anse","icon":"<svg preserveAspectRatio=\"xMidYMid meet\" viewBox=\"0 0 32 32\" width=\"1em\" height=\"1em\" ><path fill=\"currentColor\" d=\"M16 19a6.99 6.99 0 0 1-5.833-3.129l1.666-1.107a5 5 0 0 0 8.334 0l1.666 1.107A6.99 6.99 0 0 1 16 19zm4-11a2 2 0 1 0 2 2a1.98 1.98 0 0 0-2-2zm-8 0a2 2 0 1 0 2 2a1.98 1.98 0 0 0-2-2z\"/><path fill=\"currentColor\" d=\"M17.736 30L16 29l4-7h6a1.997 1.997 0 0 0 2-2V6a1.997 1.997 0 0 0-2-2H6a1.997 1.997 0 0 0-2 2v14a1.997 1.997 0 0 0 2 2h9v2H6a4 4 0 0 1-4-4V6a3.999 3.999 0 0 1 4-4h20a3.999 3.999 0 0 1 4 4v14a4 4 0 0 1-4 4h-4.835Z\"/></svg>"},{"name":"Student-admin-template","description":"A Magic Student_admin built by Vue2, element, springboot.","link":"https://github.com/yzh990918/Magic_Shop","icon":"<svg preserveAspectRatio=\"xMidYMid meet\" viewBox=\"0 0 32 32\" width=\"1em\" height=\"1em\" ><path fill=\"currentColor\" d=\"M32 14h-4v-4h-2v4h-4v2h4v4h2v-4h4v-2zM12 4a5 5 0 1 1-5 5a5 5 0 0 1 5-5m0-2a7 7 0 1 0 7 7a7 7 0 0 0-7-7zm10 28h-2v-5a5 5 0 0 0-5-5H9a5 5 0 0 0-5 5v5H2v-5a7 7 0 0 1 7-7h6a7 7 0 0 1 7 7z\"/></svg>"},{"name":"Magic Shop","description":"A magic sundry goods store built by Wechat Miniprogram.","link":"https://github.com/yzh990918/Magic_Shop","icon":"<svg preserveAspectRatio=\"xMidYMid meet\" viewBox=\"0 0 32 32\" width=\"1em\" height=\"1em\" ><circle cx=\"10\" cy=\"28\" r=\"2\" fill=\"currentColor\"/><circle cx=\"24\" cy=\"28\" r=\"2\" fill=\"currentColor\"/><path fill=\"currentColor\" d=\"M28 7H5.82L5 2.8A1 1 0 0 0 4 2H0v2h3.18L7 23.2a1 1 0 0 0 1 .8h18v-2H8.82L8 18h18a1 1 0 0 0 1-.78l2-9A1 1 0 0 0 28 7Zm-2.8 9H7.62l-1.4-7h20.53Z\"/></svg>"},{"name":"Epub Reader","description":"A Epub book Reader built by epubjs, Vue2.","link":"https://github.com/yzh990918/reader_overwrite","icon":"<svg preserveAspectRatio=\"xMidYMid meet\" viewBox=\"0 0 32 32\" width=\"1em\" height=\"1em\" ><path fill=\"currentColor\" d=\"M19 10h7v2h-7zm0 5h7v2h-7zm0 5h7v2h-7zM6 10h7v2H6zm0 5h7v2H6zm0 5h7v2H6z\"/><path fill=\"currentColor\" d=\"M28 5H4a2.002 2.002 0 0 0-2 2v18a2.002 2.002 0 0 0 2 2h24a2.002 2.002 0 0 0 2-2V7a2.002 2.002 0 0 0-2-2ZM4 7h11v18H4Zm13 18V7h11v18Z\"/></svg>"},{"name":"Magic music","description":"A magic music player built by Vue2.","link":"https://github.com/yzh990918/mymusic","icon":"<svg preserveAspectRatio=\"xMidYMid meet\" viewBox=\"0 0 32 32\" width=\"1em\" height=\"1em\" ><path fill=\"currentColor\" d=\"M25 4H10a2.002 2.002 0 0 0-2 2v14.556A3.955 3.955 0 0 0 6 20a4 4 0 1 0 4 4V12h15v8.556A3.954 3.954 0 0 0 23 20a4 4 0 1 0 4 4V6a2.002 2.002 0 0 0-2-2ZM6 26a2 2 0 1 1 2-2a2.002 2.002 0 0 1-2 2Zm17 0a2 2 0 1 1 2-2a2.003 2.003 0 0 1-2 2ZM10 6h15v4H10Z\"/></svg>"},{"name":"Koa lonely island","description":"The best Node.js Koa restfulAPI practice","link":"https://github.com/yzh990918/Node_review","icon":"<svg preserveAspectRatio=\"xMidYMid meet\" viewBox=\"0 0 32 32\" width=\"1em\" height=\"1em\" ><path fill=\"currentColor\" d=\"M12.1 2a9.8 9.8 0 0 0-5.4 1.6l6.4 6.4a2.1 2.1 0 0 1 .2 3a2.1 2.1 0 0 1-3-.2L3.7 6.4A9.84 9.84 0 0 0 2 12.1a10.14 10.14 0 0 0 10.1 10.1a10.9 10.9 0 0 0 2.6-.3l6.7 6.7a5 5 0 0 0 7.1-7.1l-6.7-6.7a10.9 10.9 0 0 0 .3-2.6A10 10 0 0 0 12.1 2Zm8 10.1a7.61 7.61 0 0 1-.3 2.1l-.3 1.1l.8.8l6.7 6.7a2.88 2.88 0 0 1 .9 2.1A2.72 2.72 0 0 1 27 27a2.9 2.9 0 0 1-4.2 0l-6.7-6.7l-.8-.8l-1.1.3a7.61 7.61 0 0 1-2.1.3a8.27 8.27 0 0 1-5.7-2.3A7.63 7.63 0 0 1 4 12.1a8.33 8.33 0 0 1 .3-2.2l4.4 4.4a4.14 4.14 0 0 0 5.9.2a4.14 4.14 0 0 0-.2-5.9L10 4.2a6.45 6.45 0 0 1 2-.3a8.27 8.27 0 0 1 5.7 2.3a8.49 8.49 0 0 1 2.4 5.9Z\"/></svg>"}]},{"name":"Utilities / CLI","projects":[{"name":"Magic CLI","description":"Monorepo enterprise level CLI tools by Rush and Pnpm","link":"https://github.com/vbs-plus/magic-cli","icon":"<svg preserveAspectRatio=\"xMidYMid meet\" viewBox=\"0 0 32 32\" width=\"1em\" height=\"1em\" ><path fill=\"currentColor\" d=\"M26 30H6a2 2 0 0 1-2-2V16a2 2 0 0 1 2-2h3v2H6v12h20V16h-3v-2h3a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2Z\"/><path fill=\"currentColor\" d=\"M13 20h6v2h-6zm7.59-11.41L17 12.17V2h-2v10.17l-3.59-3.58L10 10l6 6l6-6l-1.41-1.41z\"/></svg>"},{"name":"Magic CLI Templates","description":"Make templates simply","link":"https://github.com/vbs-plus/magic-cli-templates","icon":"<svg preserveAspectRatio=\"xMidYMid meet\" viewBox=\"0 0 32 32\" width=\"1em\" height=\"1em\" ><path fill=\"currentColor\" d=\"M28 6H18V4a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v20a2 2 0 0 0 2 2h10v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2ZM4 15h6.17l-2.58 2.59L9 19l5-5l-5-5l-1.41 1.41L10.17 13H4V4h12v20H4Zm12 13v-2a2 2 0 0 0 2-2V8h10v9h-6.17l2.58-2.59L23 13l-5 5l5 5l1.41-1.41L21.83 19H28v9Z\"/></svg>"},{"name":"ZI","description":"Use the right package manager","link":"https://github.com/vbs-plus/zi","icon":"<svg preserveAspectRatio=\"xMidYMid meet\" viewBox=\"0 0 32 32\" width=\"1em\" height=\"1em\" ><path d=\"M21.49 13.115l-9-5a1 1 0 0 0-1 0l-9 5A1.008 1.008 0 0 0 2 14v9.995a1 1 0 0 0 .52.87l9 5A1.004 1.004 0 0 0 12 30a1.056 1.056 0 0 0 .49-.135l9-5A.992.992 0 0 0 22 24V14a1.008 1.008 0 0 0-.51-.885zM11 27.295l-7-3.89v-7.72l7 3.89zm1-9.45L5.06 14L12 10.135l6.94 3.86zm8 5.56l-7 3.89v-7.72l7-3.89z\" fill=\"currentColor\"/><path d=\"M30 6h-4V2h-2v4h-4v2h4v4h2V8h4V6z\" fill=\"currentColor\"/></svg>"},{"name":"JSON TSC","description":"A plugin that makes it easier to convert JSON to Typescript interface.","link":"https://github.com/vbs-plus/json-tsc","icon":"<svg preserveAspectRatio=\"xMidYMid meet\" viewBox=\"0 0 32 32\" width=\"1em\" height=\"1em\" ><path fill=\"currentColor\" d=\"M4 20v2h4.586L2 28.586L3.414 30L10 23.414V28h2v-8H4zm25-8l-2-6h-2v10h2v-6l2 6h2V6h-2v6zm-7.666-6h-2.667A1.668 1.668 0 0 0 17 7.667v6.667A1.668 1.668 0 0 0 18.666 16h2.667A1.668 1.668 0 0 0 23 14.334V7.667A1.668 1.668 0 0 0 21.334 6zM21 14h-2V8h2zM9 7.667V10a2.002 2.002 0 0 0 2 2h2v2H9v2h4.333A1.668 1.668 0 0 0 15 14.334V12a2.002 2.002 0 0 0-2-2h-2V8h4V6h-4.334A1.668 1.668 0 0 0 9 7.667zM5 14H3v-2H1v2.333A1.668 1.668 0 0 0 2.667 16h2.667A1.668 1.668 0 0 0 7 14.334V6H5z\"/></svg>"},{"name":"Koa-template","description":"Koa Restful best template.","link":"https://github.com/yzh990918/koa-template","icon":"<svg preserveAspectRatio=\"xMidYMid meet\" viewBox=\"0 0 32 32\" width=\"1em\" height=\"1em\" ><path fill=\"currentColor\" d=\"M12.1 2a9.8 9.8 0 0 0-5.4 1.6l6.4 6.4a2.1 2.1 0 0 1 .2 3a2.1 2.1 0 0 1-3-.2L3.7 6.4A9.84 9.84 0 0 0 2 12.1a10.14 10.14 0 0 0 10.1 10.1a10.9 10.9 0 0 0 2.6-.3l6.7 6.7a5 5 0 0 0 7.1-7.1l-6.7-6.7a10.9 10.9 0 0 0 .3-2.6A10 10 0 0 0 12.1 2Zm8 10.1a7.61 7.61 0 0 1-.3 2.1l-.3 1.1l.8.8l6.7 6.7a2.88 2.88 0 0 1 .9 2.1A2.72 2.72 0 0 1 27 27a2.9 2.9 0 0 1-4.2 0l-6.7-6.7l-.8-.8l-1.1.3a7.61 7.61 0 0 1-2.1.3a8.27 8.27 0 0 1-5.7-2.3A7.63 7.63 0 0 1 4 12.1a8.33 8.33 0 0 1 .3-2.2l4.4 4.4a4.14 4.14 0 0 0 5.9.2a4.14 4.14 0 0 0-.2-5.9L10 4.2a6.45 6.45 0 0 1 2-.3a8.27 8.27 0 0 1 5.7 2.3a8.49 8.49 0 0 1 2.4 5.9Z\"/></svg>"}]},{"name":"Tools","projects":[{"name":"eslint-config","description":"Personal Eslint config presets","link":"https://github.com/yzh990918/eslint-config","icon":"<svg preserveAspectRatio=\"xMidYMid meet\" viewBox=\"0 0 24 24\" width=\"1em\" height=\"1em\" ><path fill=\"currentColor\" d=\"M7.257 9.132L11.816 6.5a.369.369 0 0 1 .368 0l4.559 2.632a.369.369 0 0 1 .184.32v5.263a.37.37 0 0 1-.184.319l-4.559 2.632a.369.369 0 0 1-.368 0l-4.559-2.632a.369.369 0 0 1-.184-.32V9.452a.37.37 0 0 1 .184-.32m16.595 2.398l-5.446-9.475c-.198-.343-.564-.596-.96-.596H6.555c-.396 0-.762.253-.96.596L.149 11.509a1.127 1.127 0 0 0 0 1.117l5.447 9.398c.197.342.563.517.959.517h10.893c.395 0 .76-.17.959-.512l5.446-9.413a1.069 1.069 0 0 0 0-1.086m-4.51 4.556a.4.4 0 0 1-.204.338L12.2 20.426a.395.395 0 0 1-.392 0l-6.943-4.002a.4.4 0 0 1-.205-.338V8.08c0-.14.083-.269.204-.338L11.8 3.74c.12-.07.272-.07.392 0l6.943 4.003a.4.4 0 0 1 .206.338z\"/></svg>"}]},{"name":"UI Design","projects":[{"name":"Onu UI","description":"Onu-UI for web glassmorphism components generate by UnoCSS","link":"https://github.com/onu-ui/onu-ui","icon":"<svg preserveAspectRatio=\"xMidYMid meet\" viewBox=\"0 0 24 24\" width=\"1em\" height=\"1em\" ><path fill=\"currentColor\" d=\"M12.86 18.4a5.57 5.57 0 1 1 11.14 0a5.57 5.57 0 0 1-11.14 0Zm0-12.8A5.57 5.57 0 1 1 24 5.602v5.013a.557.557 0 0 1-.557.557H13.417a.557.557 0 0 1-.557-.557V5.6Zm-1.72 12.8A5.57 5.57 0 1 1 0 18.4v-5.014a.557.557 0 0 1 .557-.557h10.026a.557.557 0 0 1 .557.557V18.4Z\"/></svg>"}]},{"name":"Starter Templates","projects":[{"name":"onu-starter","description":"Template for vitest-Vue3 used OnuUI","link":"https://github.com/yzh990918/onu-starter","icon":"<svg preserveAspectRatio=\"xMidYMid meet\" viewBox=\"0 0 24 24\" width=\"1em\" height=\"1em\" ><path fill=\"currentColor\" d=\"M12.86 18.4a5.57 5.57 0 1 1 11.14 0a5.57 5.57 0 0 1-11.14 0Zm0-12.8A5.57 5.57 0 1 1 24 5.602v5.013a.557.557 0 0 1-.557.557H13.417a.557.557 0 0 1-.557-.557V5.6Zm-1.72 12.8A5.57 5.57 0 1 1 0 18.4v-5.014a.557.557 0 0 1 .557-.557h10.026a.557.557 0 0 1 .557.557V18.4Z\"/></svg>"},{"name":"pmrepo-rush-starter","description":"pnpm rush monrepo template","link":"https://github.com/vbs-plus/pmrepo-rush","icon":"<svg preserveAspectRatio=\"xMidYMid meet\" viewBox=\"0 0 32 32\" width=\"1em\" height=\"1em\" ><path d=\"M16 8a5.99 5.99 0 0 0 9.471 4.885L28.586 16L30 14.586l-3.115-3.115A5.997 5.997 0 1 0 16 8zm2 0a4 4 0 1 1 4 4a4.005 4.005 0 0 1-4-4z\" fill=\"currentColor\"/><path d=\"M11 24h10v2H11z\" fill=\"currentColor\"/><path d=\"M13 28h6v2h-6z\" fill=\"currentColor\"/><path d=\"M10.815 18.14A7.185 7.185 0 0 1 8 12a8.005 8.005 0 0 1 6-7.737L13.614 2.3A10.009 10.009 0 0 0 6 12a9.18 9.18 0 0 0 3.46 7.616C10.472 20.551 11 21.081 11 22h2c0-1.84-1.11-2.866-2.185-3.86z\" fill=\"currentColor\"/><path d=\"M23.05 16a9.6 9.6 0 0 1-1.872 2.143C20.107 19.135 19 20.16 19 22h2c0-.92.526-1.45 1.535-2.386a10.966 10.966 0 0 0 2.369-2.833z\" fill=\"currentColor\"/></svg>"},{"name":"vitese-electron","description":"Vitese electron version","link":"https://github.com/yzh990918/vitese-electron","icon":"<svg preserveAspectRatio=\"xMidYMid meet\" viewBox=\"0 0 24 24\" width=\"1em\" height=\"1em\" ><path fill=\"currentColor\" d=\"M12.011 0a1.54 1.54 0 1 0 1.366 2.247c2.221 1.267 3.847 5.472 3.847 10.362c0 2.071-.289 4.056-.825 5.768a.322.322 0 0 0 .211.403a.322.322 0 0 0 .403-.21c.556-1.777.855-3.826.855-5.961c0-5.193-1.772-9.686-4.321-11.003c0-.022.003-.044.003-.067A1.54 1.54 0 0 0 12.011 0zm0 .643a.896.896 0 1 1 0 1.792a.896.896 0 1 1 0-1.792zM6.525 4.948c-2.067.008-3.647.665-4.388 1.949c-.738 1.277-.527 2.97.51 4.781a.322.322 0 0 0 .559-.32c-.935-1.63-1.117-3.092-.512-4.14c.82-1.422 3.033-1.955 5.932-1.427a.322.322 0 0 0 .115-.633a12.182 12.182 0 0 0-2.216-.21zm11.052.018a.322.322 0 0 0-.008.643c1.834.024 3.156.596 3.75 1.626c.82 1.419.18 3.594-1.718 5.837a.322.322 0 0 0 .038.453a.322.322 0 0 0 .453-.037c2.053-2.426 2.77-4.866 1.784-6.575c-.725-1.257-2.26-1.92-4.299-1.947zm-2.698.292a.323.323 0 0 0-.065.008c-1.857.398-3.833 1.175-5.731 2.271c-4.57 2.638-7.593 6.495-7.36 9.372a1.538 1.538 0 0 0 .746 2.884a1.54 1.54 0 0 0 0-3.078c-.038 0-.075.003-.113.006c-.1-2.56 2.744-6.142 7.048-8.627c1.842-1.063 3.756-1.816 5.545-2.2a.322.322 0 0 0-.07-.636zM12 11.495a1.12 1.12 0 0 0-.224.025a1.114 1.114 0 1 0 .224-.025zM4.532 13.34a.321.321 0 0 0-.232.084a.321.321 0 0 0-.021.454c1.268 1.393 2.916 2.7 4.794 3.785c4.415 2.55 9.106 3.285 11.561 1.84a1.53 1.53 0 0 0 .897.29a1.54 1.54 0 1 0-1.338-.781c-2.245 1.214-6.631.5-10.798-1.906c-1.823-1.052-3.418-2.318-4.64-3.661a.32.32 0 0 0-.223-.105zm-2.063 4.017a.896.896 0 1 1 0 1.792a.896.896 0 1 1 0-1.792zm19.062 0a.896.896 0 1 1 0 1.792a.891.891 0 0 1-.587-.22l-.006-.011a.32.32 0 0 0-.096-.092a.896.896 0 0 1 .689-1.469zM7.526 18.726a.322.322 0 0 0-.32.43C8.279 22.154 10.036 24 12.01 24c1.44 0 2.774-.982 3.813-2.711a.322.322 0 0 0-.11-.441a.322.322 0 0 0-.442.11c-.934 1.553-2.08 2.399-3.26 2.399c-1.642 0-3.208-1.647-4.2-4.418a.322.322 0 0 0-.286-.213z\"/></svg>"},{"name":"vitese","description":"Template for vitest-vue3","link":"https://github.com/yzh990918/vitest-vue-starter","icon":"<svg preserveAspectRatio=\"xMidYMid meet\" viewBox=\"0 0 32 32\" width=\"1em\" height=\"1em\" ><path fill=\"currentColor\" d=\"M27.562 26L17.17 8.928l2.366-3.888L17.828 4L16 7.005L14.17 4l-1.708 1.04l2.366 3.888L4.438 26H2v2h28v-2ZM16 10.85L25.22 26H17v-8h-2v8H6.78Z\"/></svg>"},{"name":"vitese-react","description":"Template for vitest-react","link":"https://github.com/yzh990918/vitest-react-starter","icon":"<svg preserveAspectRatio=\"xMidYMid meet\" viewBox=\"0 0 24 24\" width=\"1em\" height=\"1em\" ><path fill=\"currentColor\" d=\"M14.23 12.004a2.236 2.236 0 0 1-2.235 2.236a2.236 2.236 0 0 1-2.236-2.236a2.236 2.236 0 0 1 2.235-2.236a2.236 2.236 0 0 1 2.236 2.236zm2.648-10.69c-1.346 0-3.107.96-4.888 2.622c-1.78-1.653-3.542-2.602-4.887-2.602c-.41 0-.783.093-1.106.278c-1.375.793-1.683 3.264-.973 6.365C1.98 8.917 0 10.42 0 12.004c0 1.59 1.99 3.097 5.043 4.03c-.704 3.113-.39 5.588.988 6.38c.32.187.69.275 1.102.275c1.345 0 3.107-.96 4.888-2.624c1.78 1.654 3.542 2.603 4.887 2.603c.41 0 .783-.09 1.106-.275c1.374-.792 1.683-3.263.973-6.365C22.02 15.096 24 13.59 24 12.004c0-1.59-1.99-3.097-5.043-4.032c.704-3.11.39-5.587-.988-6.38a2.167 2.167 0 0 0-1.092-.278zm-.005 1.09v.006c.225 0 .406.044.558.127c.666.382.955 1.835.73 3.704c-.054.46-.142.945-.25 1.44a23.476 23.476 0 0 0-3.107-.534A23.892 23.892 0 0 0 12.769 4.7c1.592-1.48 3.087-2.292 4.105-2.295zm-9.77.02c1.012 0 2.514.808 4.11 2.28c-.686.72-1.37 1.537-2.02 2.442a22.73 22.73 0 0 0-3.113.538a15.02 15.02 0 0 1-.254-1.42c-.23-1.868.054-3.32.714-3.707c.19-.09.4-.127.563-.132zm4.882 3.05c.455.468.91.992 1.36 1.564c-.44-.02-.89-.034-1.345-.034c-.46 0-.915.01-1.36.034c.44-.572.895-1.096 1.345-1.565zM12 8.1c.74 0 1.477.034 2.202.093c.406.582.802 1.203 1.183 1.86c.372.64.71 1.29 1.018 1.946c-.308.655-.646 1.31-1.013 1.95c-.38.66-.773 1.288-1.18 1.87a25.64 25.64 0 0 1-4.412.005a26.64 26.64 0 0 1-1.183-1.86c-.372-.64-.71-1.29-1.018-1.946a25.17 25.17 0 0 1 1.013-1.954c.38-.66.773-1.286 1.18-1.868A25.245 25.245 0 0 1 12 8.098zm-3.635.254c-.24.377-.48.763-.704 1.16c-.225.39-.435.782-.635 1.174c-.265-.656-.49-1.31-.676-1.947c.64-.15 1.315-.283 2.015-.386zm7.26 0c.695.103 1.365.23 2.006.387c-.18.632-.405 1.282-.66 1.933a25.952 25.952 0 0 0-1.345-2.32zm3.063.675c.484.15.944.317 1.375.498c1.732.74 2.852 1.708 2.852 2.476c-.005.768-1.125 1.74-2.857 2.475c-.42.18-.88.342-1.355.493a23.966 23.966 0 0 0-1.1-2.98c.45-1.017.81-2.01 1.085-2.964zm-13.395.004c.278.96.645 1.957 1.1 2.98a23.142 23.142 0 0 0-1.086 2.964c-.484-.15-.944-.318-1.37-.5c-1.732-.737-2.852-1.706-2.852-2.474c0-.768 1.12-1.742 2.852-2.476c.42-.18.88-.342 1.356-.494zm11.678 4.28c.265.657.49 1.312.676 1.948c-.64.157-1.316.29-2.016.39a25.819 25.819 0 0 0 1.341-2.338zm-9.945.02c.2.392.41.783.64 1.175c.23.39.465.772.705 1.143a22.005 22.005 0 0 1-2.006-.386c.18-.63.406-1.282.66-1.933zM17.92 16.32c.112.493.2.968.254 1.423c.23 1.868-.054 3.32-.714 3.708c-.147.09-.338.128-.563.128c-1.012 0-2.514-.807-4.11-2.28c.686-.72 1.37-1.536 2.02-2.44c1.107-.118 2.154-.3 3.113-.54zm-11.83.01c.96.234 2.006.415 3.107.532c.66.905 1.345 1.727 2.035 2.446c-1.595 1.483-3.092 2.295-4.11 2.295a1.185 1.185 0 0 1-.553-.132c-.666-.38-.955-1.834-.73-3.703c.054-.46.142-.944.25-1.438zm4.56.64c.44.02.89.034 1.345.034c.46 0 .915-.01 1.36-.034c-.44.572-.895 1.095-1.345 1.565c-.455-.47-.91-.993-1.36-1.565z\"/></svg>"},{"name":"vitese-h5","description":"Template for vitest-vue3 h5","link":"https://github.com/yzh990918/vitese-h5-starter","icon":"<svg preserveAspectRatio=\"xMidYMid meet\" viewBox=\"0 0 32 32\" width=\"1em\" height=\"1em\" ><path fill=\"currentColor\" d=\"M23 7h4v4h-4zm0 6h4v4h-4zm-6-6h4v4h-4zm0 6h4v4h-4z\"/><circle cx=\"14.5\" cy=\"24.5\" r=\"1.5\" fill=\"currentColor\"/><path fill=\"currentColor\" d=\"M21 30H8a2.002 2.002 0 0 1-2-2V4a2.002 2.002 0 0 1 2-2h13v2H8v24h13v-8h2v8a2.002 2.002 0 0 1-2 2Z\"/></svg>"},{"name":"vite-vue2-starter","description":"Template for vite vue2","link":"https://github.com/yzh990918/vite-vue2-start","icon":"<svg preserveAspectRatio=\"xMidYMid meet\" viewBox=\"0 0 32 32\" width=\"1em\" height=\"1em\" ><path fill=\"currentColor\" d=\"M27.562 26L17.17 8.928l2.366-3.888L17.828 4L16 7.005L14.17 4l-1.708 1.04l2.366 3.888L4.438 26H2v2h28v-2ZM16 10.85L25.22 26H17v-8h-2v8H6.78Z\"/></svg>"},{"name":"ts-cli-template","description":"Typescript cli starter","link":"https://github.com/yzh990918/ts-cli-template","icon":"<svg preserveAspectRatio=\"xMidYMid meet\" viewBox=\"0 0 24 24\" width=\"1em\" height=\"1em\" ><path fill=\"currentColor\" d=\"M1.125 0C.502 0 0 .502 0 1.125v21.75C0 23.498.502 24 1.125 24h21.75c.623 0 1.125-.502 1.125-1.125V1.125C24 .502 23.498 0 22.875 0zm17.363 9.75c.612 0 1.154.037 1.627.111a6.38 6.38 0 0 1 1.306.34v2.458a3.95 3.95 0 0 0-.643-.361a5.093 5.093 0 0 0-.717-.26a5.453 5.453 0 0 0-1.426-.2c-.3 0-.573.028-.819.086a2.1 2.1 0 0 0-.623.242c-.17.104-.3.229-.393.374a.888.888 0 0 0-.14.49c0 .196.053.373.156.529c.104.156.252.304.443.444s.423.276.696.41c.273.135.582.274.926.416c.47.197.892.407 1.266.628c.374.222.695.473.963.753c.268.279.472.598.614.957c.142.359.214.776.214 1.253c0 .657-.125 1.21-.373 1.656a3.033 3.033 0 0 1-1.012 1.085a4.38 4.38 0 0 1-1.487.596c-.566.12-1.163.18-1.79.18a9.916 9.916 0 0 1-1.84-.164a5.544 5.544 0 0 1-1.512-.493v-2.63a5.033 5.033 0 0 0 3.237 1.2c.333 0 .624-.03.872-.09c.249-.06.456-.144.623-.25c.166-.108.29-.234.373-.38a1.023 1.023 0 0 0-.074-1.089a2.12 2.12 0 0 0-.537-.5a5.597 5.597 0 0 0-.807-.444a27.72 27.72 0 0 0-1.007-.436c-.918-.383-1.602-.852-2.053-1.405c-.45-.553-.676-1.222-.676-2.005c0-.614.123-1.141.369-1.582c.246-.441.58-.804 1.004-1.089a4.494 4.494 0 0 1 1.47-.629a7.536 7.536 0 0 1 1.77-.201zm-15.113.188h9.563v2.166H9.506v9.646H6.789v-9.646H3.375z\"/></svg>"},{"name":"ts-starter","description":"Typescript Vitest starter","link":"https://github.com/yzh990918/ts-vitest-starter","icon":"<svg preserveAspectRatio=\"xMidYMid meet\" viewBox=\"0 0 24 24\" width=\"1em\" height=\"1em\" ><path fill=\"currentColor\" d=\"M1.125 0C.502 0 0 .502 0 1.125v21.75C0 23.498.502 24 1.125 24h21.75c.623 0 1.125-.502 1.125-1.125V1.125C24 .502 23.498 0 22.875 0zm17.363 9.75c.612 0 1.154.037 1.627.111a6.38 6.38 0 0 1 1.306.34v2.458a3.95 3.95 0 0 0-.643-.361a5.093 5.093 0 0 0-.717-.26a5.453 5.453 0 0 0-1.426-.2c-.3 0-.573.028-.819.086a2.1 2.1 0 0 0-.623.242c-.17.104-.3.229-.393.374a.888.888 0 0 0-.14.49c0 .196.053.373.156.529c.104.156.252.304.443.444s.423.276.696.41c.273.135.582.274.926.416c.47.197.892.407 1.266.628c.374.222.695.473.963.753c.268.279.472.598.614.957c.142.359.214.776.214 1.253c0 .657-.125 1.21-.373 1.656a3.033 3.033 0 0 1-1.012 1.085a4.38 4.38 0 0 1-1.487.596c-.566.12-1.163.18-1.79.18a9.916 9.916 0 0 1-1.84-.164a5.544 5.544 0 0 1-1.512-.493v-2.63a5.033 5.033 0 0 0 3.237 1.2c.333 0 .624-.03.872-.09c.249-.06.456-.144.623-.25c.166-.108.29-.234.373-.38a1.023 1.023 0 0 0-.074-1.089a2.12 2.12 0 0 0-.537-.5a5.597 5.597 0 0 0-.807-.444a27.72 27.72 0 0 0-1.007-.436c-.918-.383-1.602-.852-2.053-1.405c-.45-.553-.676-1.222-.676-2.005c0-.614.123-1.141.369-1.582c.246-.441.58-.804 1.004-1.089a4.494 4.494 0 0 1 1.47-.629a7.536 7.536 0 0 1 1.77-.201zm-15.113.188h9.563v2.166H9.506v9.646H6.789v-9.646H3.375z\"/></svg>"},{"name":"ant-design-pro-starter","description":"Ant Design Pro Starter","link":"https://github.com/vbs-plus/magic-cli-templates/tree/master/packages/ant-design-pro-starter","icon":"<svg preserveAspectRatio=\"xMidYMid meet\" viewBox=\"0 0 24 24\" width=\"1em\" height=\"1em\" ><path fill=\"currentColor\" d=\"M17.451 6.68c.51-.506.51-1.33 0-1.837L15.578 2.97l.003.002l-2.554-2.55a1.463 1.463 0 0 0-2.05.013L.427 10.98a1.443 1.443 0 0 0 0 2.047l10.549 10.54a1.45 1.45 0 0 0 2.05 0l4.423-4.42a1.297 1.297 0 0 0 0-1.838a1.305 1.305 0 0 0-1.84 0l-3.35 3.354a.346.346 0 0 1-.495 0l-8.427-8.419a.346.346 0 0 1 0-.495l8.424-8.42c.01-.01.024-.018.035-.029a.34.34 0 0 1 .46.03l3.354 3.35a1.3 1.3 0 0 0 1.841 0zm-8.245 5.376a2.848 2.846 0 1 0 5.697 0a2.848 2.846 0 1 0-5.697 0zm14.368-1.034L20.28 7.743a1.303 1.303 0 0 0-1.841.003a1.297 1.297 0 0 0 0 1.838l2.224 2.222c.14.139.14.356 0 .495l-2.192 2.19a1.297 1.297 0 0 0 0 1.837a1.305 1.305 0 0 0 1.84 0l3.264-3.26a1.445 1.445 0 0 0-.002-2.047Z\"/></svg>"},{"name":"ant-design-simple-starter","description":"Ant Design Pro Simple Starter","link":"https://github.com/vbs-plus/magic-cli-templates/tree/master/packages/ant-design-simple-starter","icon":"<svg preserveAspectRatio=\"xMidYMid meet\" viewBox=\"0 0 24 24\" width=\"1em\" height=\"1em\" ><path fill=\"currentColor\" d=\"M17.451 6.68c.51-.506.51-1.33 0-1.837L15.578 2.97l.003.002l-2.554-2.55a1.463 1.463 0 0 0-2.05.013L.427 10.98a1.443 1.443 0 0 0 0 2.047l10.549 10.54a1.45 1.45 0 0 0 2.05 0l4.423-4.42a1.297 1.297 0 0 0 0-1.838a1.305 1.305 0 0 0-1.84 0l-3.35 3.354a.346.346 0 0 1-.495 0l-8.427-8.419a.346.346 0 0 1 0-.495l8.424-8.42c.01-.01.024-.018.035-.029a.34.34 0 0 1 .46.03l3.354 3.35a1.3 1.3 0 0 0 1.841 0zm-8.245 5.376a2.848 2.846 0 1 0 5.697 0a2.848 2.846 0 1 0-5.697 0zm14.368-1.034L20.28 7.743a1.303 1.303 0 0 0-1.841.003a1.297 1.297 0 0 0 0 1.838l2.224 2.222c.14.139.14.356 0 .495l-2.192 2.19a1.297 1.297 0 0 0 0 1.837a1.305 1.305 0 0 0 1.84 0l3.264-3.26a1.445 1.445 0 0 0-.002-2.047Z\"/></svg>"},{"name":"vue3-element-admin-starter","description":"Vue3 element-plus admin-starter","link":"https://github.com/vbs-plus/magic-cli-templates/tree/master/packages/vue3-element-admin-starter","icon":"<svg preserveAspectRatio=\"xMidYMid meet\" viewBox=\"0 0 1024 1024\" width=\"1em\" height=\"1em\" ><path fill=\"currentColor\" d=\"M839.7 734.7c0 33.3-17.9 41-17.9 41S519.7 949.8 499.2 960c-10.2 5.1-20.5 5.1-30.7 0c0 0-314.9-184.3-325.1-192c-5.1-5.1-10.2-12.8-12.8-20.5V368.6c0-17.9 20.5-28.2 20.5-28.2L466 158.6c12.8-5.1 25.6-5.1 38.4 0c0 0 279 161.3 309.8 179.2c17.9 7.7 28.2 25.6 25.6 46.1c-.1-5-.1 317.5-.1 350.8zM714.2 371.2c-64-35.8-217.6-125.4-217.6-125.4c-7.7-5.1-20.5-5.1-30.7 0L217.6 389.1s-17.9 10.2-17.9 23v297c0 5.1 5.1 12.8 7.7 17.9c7.7 5.1 256 148.5 256 148.5c7.7 5.1 17.9 5.1 25.6 0c15.4-7.7 250.9-145.9 250.9-145.9s12.8-5.1 12.8-30.7v-74.2l-276.5 169v-64c0-17.9 7.7-30.7 20.5-46.1L745 535c5.1-7.7 10.2-20.5 10.2-30.7v-66.6l-279 169v-69.1c0-15.4 5.1-30.7 17.9-38.4l220.1-128zM919 135.7c0-5.1-5.1-7.7-7.7-7.7h-58.9V66.6c0-5.1-5.1-5.1-10.2-5.1l-30.7 5.1c-5.1 0-5.1 2.6-5.1 5.1V128h-56.3c-5.1 0-5.1 5.1-7.7 5.1v38.4h69.1v64c0 5.1 5.1 5.1 10.2 5.1l30.7-5.1c5.1 0 5.1-2.6 5.1-5.1v-56.3h64l-2.5-38.4z\"/></svg>"}]}],"_id":"content:projects.json","_type":"json","title":"Projects","_source":"content","_file":"projects.json","_extension":"json","storageMeta":{"atime":"2023-06-16T10:26:05.626Z","mtime":"2023-06-16T10:26:05.626Z","size":6310}}]