如下圖 是要實現的效果

如下為代碼塊
//NavBar.vue
<template>
<div id="vab-bar">
<div class="nav-bar">
<div class="left"><slot name="left"></slot></div>
<div class="center"><slot name="center"></slot></div>
<div class="right"><slot name="right"></slot></div>
</div>
</div>
</template>
<script>
export default {
name: 'NavBar',
}
</script>
<style>
.nav-bar{
display: flex;
line-height: 44px;
height: 44px;
text-align: center;
}
.left, .right{
width: 60px;
background-color: blue
}
.center{
flex:1;
background-color:red;
color: white
}
</style>
在main.vue 應用的時候出現了路徑問題

合併tabbar 和navbar到達如下效果

點擊首頁

嵌套路由router-view的位置一定要放正確
NavBar与TabBar整合技巧

本文探讨了在Vue中实现自定义NavBar组件的方法,并解决了在main.vue应用时遇到的路径问题。通过调整slot布局和样式,成功实现了NavBar与TabBar的整合,达到预期的视觉效果。点击首页时,正确配置嵌套路由router-view的位置至关重要。
1861

被折叠的 条评论
为什么被折叠?



