1. IntroductionAs expected, sitting or standing for a long time will put a lot of pressure on the waist. Let me make it clear that I don’t have a dislocated waist, I just had a puncture surgery and there are many stitches on my body that have not healed well, so it will put a certain pressure on my stomach and waist. The previous article has written about the development of the layout, please refer to "Vue3 (III) Website Homepage Layout Development", but when we write code, we must inherit the excellent code style and encapsulation characteristics, so here we modify the code again and extract 2. Component Development 1. Component composition Create components under It consists of two pairs of tags: 2. Development of some header componentsAs shown in the red circle in the figure above, this is the common part we want to extract, that is, the development of components. Create components under components. The component code of header is as follows: html <template> <a-layout-header class="header"> <div class="logo" /> <a-menu theme="dark" mode="horizontal" v-model:selectedKeys="selectedKeys1" :style="{ lineHeight: '64px' }" > <a-menu-item key="1">nav 11122</a-menu-item> <a-menu-item key="2">nav 2</a-menu-item> <a-menu-item key="3">nav 3</a-menu-item> </a-menu> </a-layout-header> </template> <script lang="ts"> import { defineComponent } from 'vue'; export default defineComponent({ name: 'TheHeader', }); </script> 3. Development of footer componentAs shown in the figure above, we need to develop the footer component. The sample code is as follows: html <template> <a-layout-footer style="text-align: center"> Software Tester©2021 Created by Liuge20211017 </a-layout-footer> </template> <script lang="ts"> import { defineComponent } from 'vue'; export default defineComponent({ name: 'TheFooter', }); </script> 4. Modify App.vueThe sample code is as follows: html <template> <a-layout> <the-header></the-header> <router-view/> <the-footer></the-footer> </a-layout> </template> <style> #components-layout-demo-top-side-2 .logo { float: left; width: 120px; height: 31px; margin: 16px 24px 16px 0; background: rgba(255, 255, 255, 0.3); } .ant-row-rtl #components-layout-demo-top-side-2 .logo { float: right; margin: 16px 0 16px 24px; } .site-layout-background { background: #fff; } </style> <script> import TheHeader from "@/components/the-header"; import TheFooter from "@/components/the-footer"; export default { components: TheHeader, TheFooter } } </script> 5. Remove Helloword components and related codesThe home is modified as follows: html <template> <a-layout> <a-layout-sider width="200" style="background: #fff"> <a-menu mode="inline" v-model:selectedKeys="selectedKeys2" v-model:openKeys="openKeys" :style="{ height: '100%', borderRight: 0 }" > <a-sub-menu key="sub1"> <template #title> <span> <user-outlined /> subnav 1 </span> </template> <a-menu-item key="1">option1</a-menu-item> <a-menu-item key="2">option2</a-menu-item> <a-menu-item key="3">option3</a-menu-item> <a-menu-item key="4">option4</a-menu-item> </a-sub-menu> <a-sub-menu key="sub2"> <template #title> <span> <laptop-outlined /> subnav 2 </span> </template> <a-menu-item key="5">option5</a-menu-item> <a-menu-item key="6">option6</a-menu-item> <a-menu-item key="7">option7</a-menu-item> <a-menu-item key="8">option8</a-menu-item> </a-sub-menu> <a-sub-menu key="sub3"> <template #title> <span> <notification-outlined /> subnav 3 </span> </template> <a-menu-item key="9">option9</a-menu-item> <a-menu-item key="10">option10</a-menu-item> <a-menu-item key="11">option11</a-menu-item> <a-menu-item key="12">option12</a-menu-item> </a-sub-menu> </a-menu> </a-layout-sider> <a-layout-content :style="{ background: '#fff', padding: '24px', margin: 0, minHeight: '280px' }" > Content </a-layout-content> </a-layout> </template> <script lang="ts"> import { defineComponent } from 'vue'; export default defineComponent({ name: 'Home', }); </script> 6. Restart the service to viewRecompile and access the page again. The results are as follows: 3. FinallyThis is the end of this article about the development of Vue3 (IV) components. For more relevant Vue3 component development content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Copy and paste is the enemy of packaging
>>: CSS transparent border background-clip magic
This article shares with you the tutorial of inst...
Since HTML email is not an independent HOST page o...
Table of contents Preface 1. ss command 2. Overal...
Sometimes you need to set several areas on a pict...
What is margin-top collapse Margin-top collapse i...
Although W3C has established some standards for HT...
Project scenario: There is a <ul> tag on th...
<br />In the past, creating a printer-friend...
Next, I will create two tables and execute a seri...
Table of contents Preface design accomplish summa...
Require The div under the body is vertically cent...
Detailed example of clearing tablespace fragmenta...
Table of contents 1. Differences between option A...
In fact, this is also a clickbait title, and it c...
Recently, I have been working on a large-screen d...