Create the main navigation bar area MainTabBar.vue, here is actually the navigation bar area Tabbar.vue into an independent component, let it be displayed in the MainTabBar, because the subsequent implementation of the TabBarItem in the navigation bar area, so all have been extracted Separation and independence.
Up to this point, a bottom navigation bar area has been created, but there is no content inside, so the height of Tabbar.vue is 0, and no effect can be seen. Just add a little height to the style of Tabbar.vue. I know what the navigation bar area looks like now. This hard-coded height will be removed later, and the navigation bar will be supported by the content of the TabBarItem
height: 50px;
② Then create TabBarItem, which is each option
These options are to be inserted into Tabbar.vue, so Tabbar.vue must set a slot so that each Item can be added
<slot></slot>
tabbar -> TabbarItem.vue
Display:flex has been set in the navigation bar; here the item is set to flex:1; the height of the item is given to 49px, which is the height of the usual navigation bar. If there is a height, the navigation bar can be opened, and the style of the icon in the item must be set.
The reason for using named slots for pictures and text is that TabBarItem is also a separate component separated out. In the end, TabBar.vue and TabBarItem.vue will be referenced and presented in MainTabBar.
These two components are referenced and used in MainTabBar.vue, and parameters are passed to the sub-layer, so use props to receive it in the sub-layer:
The final realization of the component needs: each icon corresponding to the navigation bar and the corresponding display page
The path of the icon is modified by itself in MainTabBar.vue. If the corresponding display page is required, vue-router needs to be installed and configured
Here is a combination of lazy loading and simple configuration of two corresponding pages, "Home" and "Category"