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中 切换几次 就卡死 不明原因


回答:

可能是页面栈满了 小程序页面最多10层
Uniapp中自定义tabbar,切换几次就卡死崩溃?
尝试把 navigateTo 改为 redirectTo 或 switchTab


回答:

handleClick(path) {

uni.redirectTo({

url: path,

})

}

以上是 Uniapp中自定义tabbar,切换几次就卡死崩溃? 的全部内容, 来源链接: utcz.com/p/934591.html

回到顶部