独孤雄鹰
独孤雄鹰
  • 发布:2018-10-26 16:02
  • 更新:2021-07-05 09:20
  • 阅读:19595

uniapp使用uni.switchTab跳转tabbar页报错

分类:uni-app

pages.js代码

{  
    "pages" : [  
        //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages  
        {  
            "path" : "pages/start/start",  
            "style" : {  
                "navigationBarTitleText" : "详情",  
                "app-plus" : {  
                    "titleNView" : false  
                }  
            }  
        },  
        {  
            "path" : "pages/index/index",  
            "style" : {  
                "navigationBarTitleText" : "uni-app",  
                "app-plus" : {  
                    "titleNView" : false ,//禁用原生导航栏  
                    "bounce" : "none",  
                    "scrollIndicator" : "none"  
                }  
            }  
        },  
        {  
            "path" : "pages/renmai/renmai",  
            "style" : {  
                "navigationBarTitleText" : "uni-app",  
                "app-plus" : {  
                    "titleNView" : false //禁用原生导航栏  
                }  
            }  
        },  
        {  
            "path" : "pages/event/event",  
            "style" : {  
                "navigationBarTitleText" : "uni-app",  
                "app-plus" : {  
                    "titleNView" : {  
                        "splitLine":{"color":"#d8d8d8"}  
                    }  
                }  
            }  
        },  
        {  
            "path" : "pages/user/user",  
            "style" : {  
                "navigationBarTitleText" : "uni-app",  
                "app-plus" : {  
                    "titleNView" : false //禁用原生导航栏  
                }  
            }  
        },  

        {  
            "path" : "pages/news/news",  
            "style" : {}  
        },  
        {  
            "path" : "pages/main/main",  
            "style" : {}  
        }  
    ],  
    "globalStyle" : {  
        "navigationBarTextStyle" : "black",  
        "navigationBarTitleText" : "uni-app",  
        "navigationBarBackgroundColor" : "#ffffff",  
        "backgroundColor" : "#F8F8F8"  
    },  
    "tabBar" : {  
        "color" : "#7A7E83",  
        "selectedColor" : "#007AFF",  
        "borderStyle" : "#dddddd",  
        "backgroundColor" : "#ffffff",  
        "list" : [  
            {  
                "pagePath" : "pages/index/index",  
                "iconPath" : "static/component.png",  
                "selectedIconPath" : "static/componentHL.png",  
                "text" : "组件"  
            },  
            {  
                "pagePath" : "pages/renmai/renmai",  
                "iconPath" : "static/api.png",  
                "selectedIconPath" : "static/apiHL.png",  
                "text" : "接口"  
            },  
            {  
                "pagePath" : "pages/user/user",  
                "iconPath" : "static/template.png",  
                "selectedIconPath" : "static/templateHL.png",  
                "text" : "模板"  
            }  
        ]  
    }  
}

start.vue页代码

<template>  
    <view>  

        <view class="content">  
            <text class="title">{{title}}</text>  
            <text class="title">sfdafsdasfd</text>  

        </view>  

    </view>  
</template>  

<script>  

    export default {  
        data: {  
            title:'开屏页',  
        },  
        onShow() {  
            uni.switchTab({  
                url: '../index/index'  
            });  
        }  
    }  
</script>

跳转报错
OnWebviewEvent: __DOMReady, WebviewId: 1 not found

这报错信息是什么意思啊?是我配置的不对吗?

2018-10-26 16:02 负责人:无 分享
已邀请:
独孤雄鹰

独孤雄鹰 (作者)

<script>  

    export default {  
        data: {  
            title:'开屏页',  
        },  
        onShow() {  

            setTimeout(function() {  
                uni.switchTab({  
                    url: '/pages/index/index'  
                });  
            }, 5000)  
        }  
    }  
</script>

加上setTimeout就不报错了,是不是因为跳转的快,index页面还没有渲染完成的原因啊?

4***@qq.com

4***@qq.com - xiaobai

加了延时器的话还会在原来的页面停留而且跳转动画太难看。。。。

小菜啊

小菜啊 - 业精于勤荒于嬉

把../index/index改成/pages/index/index就好了

该问题目前已经被锁定, 无法添加新回复