Uniapp中自定义tabbar,切换几次就卡死崩溃?
<template>
<!-- <u-tabbar :value="tabName" @change="handleClick" :fixed="true" :placeholder="true" :safeAreaInsetBottom="true"
activeColor="#FFF" inactiveColor="#dadada" style="background-color: aquamarine;">
<u-tabbar-item text="首页" icon="home" name="home"></u-tabbar-item>
<u-tabbar-item text="地图" icon="map" name="map"></u-tabbar-item>
<u-tabbar-item text="菜单" name="menu" icon="file-text"></u-tabbar-item>
<u-tabbar-item text="我的" name="me" icon="account"></u-tabbar-item>
</u-tabbar> -->
<view class="k-tabbar"
:class="{ '': curThemeType == '蓝色海洋' || curThemeType == '大字版', 'k-tabbar-red': curThemeType == '中国红', 'k-tabbar-green': curThemeType == '碧海蓝天' }">
<template v-for="item in tabData">
<view :key="item.name" class="tabbar-content" :class="item.name == tabName ? 'active' : ''"
@click="handleClick(item.path)">
<u-icon :name="item.icon" :color="item.name == tabName ? '#fff' : '#bbb'"></u-icon>
<view>{{ item.title }}</view>
</view>
</template>
</view>
</template>
<script>
export default {
props: {
tabName: {
type: String,
default: '',
}
},
options: { styleIsolation: 'shared' },
data() {
return {
tabData: [
{
name: "home",
path: "/pages/index/index",
icon: "home",
title: "首页",
},
{
name: "map",
title: "地图",
path: "/pages/map/index",
icon: "map"
},
{
name: "menu",
title: "菜单",
path: "/pages/menu/index",
icon: "file-text"
}, {
name: "me",
title: "我的",
path: "/pages/my/index",
icon: "account"
}
]
}
},
methods: {
handleClick(path) {
uni.navigateTo({
url: path,
})
},
}
}
</script>
<style lang="scss" scoped>
// ::v-deep .u-tabbar__content__item-wrapper {
// background-color: #1D62FF;
// color: #fff;
// }
.k-tabbar {
display: flex;
justify-content: space-around;
font-size: 12px;
z-index: 999;
padding-top: 10px;
left: 0;
position: fixed;
bottom: 0;
width: 100%;
background-color: $blue;
&-red {
background: $red;
}
&-green {
background: $green;
}
.tabbar-content {
display: flex;
flex-direction: column;
align-items: center;
height: 50px;
color: #bbb;
&.active {
color: #fff;
}
}
}
</style>
小程序 app中 切换几次 就卡死 不明原因
回复
1个回答
test
2024-06-30
可能是页面栈满了 小程序页面最多10层尝试把 navigateTo 改为 redirectTo 或 switchTab
回复
适合作为回答的
- 经过验证的有效解决办法
- 自己的经验指引,对解决问题有帮助
- 遵循 Markdown 语法排版,代码语义正确
不该作为回答的
- 询问内容细节或回复楼层
- 与题目无关的内容
- “赞”“顶”“同问”“看手册”“解决了没”等毫无意义的内容