x***@126.com
x***@126.com
  • 发布:2018-10-30 11:28
  • 更新:2019-04-09 11:04
  • 阅读:3086

使用nvue TabBar报错:launch webview id is not ready__ERROR

分类:uni-app

从其他页面带参数跳转到nvue ,tabbar,报错:11:25:59.768 25:59.145 17052 17078 E console : launch webview id is not ready__ERROR
代码如下:

<template>  
    <div>  
        <tabs @change="changeTab" :index="tabIndex">  
            <tab-bar>  
                <div class="tab-bar-item" v-for="(tabBar, t) in tabBars" :key="t" :ref="tabBar.id + t">  
                    <text class="tab-bar-title" :class="[tabIndex === t ? 'active' : '']">{{tabBar.typeName}}</text>  
                </div>  
            </tab-bar>  
            <tab-content>  
                <list class="list" @loadmore="loadMore(index1)" loadmoreoffset="10" v-for="(tab,index1) in shows.data" :key="index1">  
                    <refresh class="refresh" @refresh="onrefresh" @pullingdown="onpullingdown" :display="refreshing ? 'show' : 'hide'">  
                        <text class="refresh-text">{{refreshText}}</text>  
                    </refresh>  
                    <cell v-for="(newsitem,index2) in tab" :key="index2">  

                        <media-list :data="newsitem" @click="goDetail(newsitem)"></media-list>  
                    </cell>  
                    <cell class="loadmore">  
                        <text class="loadmore-text">{{tab.loadingText}}</text>  
                    </cell>  
                </list>  
            </tab-content>  
        </tabs>  
    </div>  
</template>  

<script>  
    import tabContent from '@/components/nvue/tabContent.nvue'  
    import tabBar from '@/components/nvue/tabBar.nvue'  
    import tabs from '@/components/nvue/tabs.nvue'  
    import mediaList from '@/components/nvue/mediaList.nvue'  
    import {getUrl} from '../../../common/oss';  
    import {All} from '../../../api/cms/category';  
    import {page} from '../../../api/cms/page';  
    const dom = weex.requireModule('dom')  
    export default {  
        components: {  
            tabContent,  
            tabBar,  
            tabs,  
            mediaList  
        },  
        data() {  
            return {  
                refreshing: false,  
                current_rotate:0,  
                refreshText:"下拉可以刷新",  
                tabIndex: 0,  
                tabBars: [  
                    {  
                        id: "tab0",  
                        typeName: "最新",  
                        orderBy:"createdStamp",  
                        sort: "desc",  
                        page: 1,  
                        params: {}  
                    },  
                    {  
                        id: "tab1",  
                        typeName: "热帖",  
                        orderBy:"hotValue",  
                        sort: "desc",  
                        page: 1,  
                        params: {}  
                    },  
                    {  
                        id: "tab2",  
                        typeName: "精华",  
                        orderBy:"createdStamp",  
                        sort: "desc",  
                        page: 1,  
                        params: {  
                            isEssence: 'Y',  
                        }  
                    },  
                    {  
                        id: "tab3",  
                        typeName: "全部",  
                        orderBy:"createdStamp",  
                        sort: "desc",  
                        page: 1,  
                        params: {}  
                    }  
                ],  
                shows:[  
                ],  
            }  
        },  
        onLoad(e) {  
            console.log("navigator:" + e.navigateValue)  
            this.refreshing = true;  
            this.showTypeId = e.navigateValue;  
            createnewList()  
        },  
        onUnload(){  
            this.tabIndex = 0;  
        },  
        methods: {  
            async loadShows(index){  
                var that = this;  
                page(that.getParams(that.tabBars[index].params,that.tabBars[index].page,   
                4, that.tabBars[index].orderBy, that.tabBars[index].sort)).then(function(res){  
                    console.log(JSON.stringify(res))  
                    if(res.total > 0){  
                        for(var i = 0; i< res.data.length; i++){  

                            res.data[i].baseUrl = getUrl();  
                            that.shows[index].data.push(res.data[i]);  
                        }  

                        if(that.tabBars[index].page ==1 ){  
                            that.refreshing = false;  
                        }  
                        that.tabBars[index].page = that.tabBars[index].page + 1;  
                    }  
                })  
            },  
            getParams(p, page, pageSize, orderBy, sort){  
                let params = p || {};  
                params.categoryTypeId = this.showTypeId;  
                params.showStatusId = "SHOW_CHECKED";  
                params.page=page;  
                params.limit=pageSize;  
                params.orderBy = orderBy;  
                params.sort = sort;  
                return params  
            },  
            goDetail(e){  
                uni.navigateTo({  
                    url: 'pages/cms/detail?data=' + e.title  
                })  
            },  
            onrefresh(event) {  
                uni.showToast({  
                    title: "refresh",  
                    icon:"none"  
                });  
                this.refreshText = "正在刷新...";  
                this.refreshing = true;  
                this.tabBars[this.tabIndex].page = 1;  
                loadShows(this.tabIndex);  
            },  
            onpullingdown(event) {  
                if(this.refreshing){  
                    return;  
                }  
                if(Math.abs(event.pullingDistance) > Math.abs(event.viewHeight)){  
                  this.refreshText = "释放立即刷新";  
                }else{  
                  this.refreshText = "下拉可以刷新";  
                }  
            },  
            loadMore(e) {  
                this.loadShows(e);  
            },  
            addData(e) {  
                this.loadShows(e);  
            },  
            close(index1,index2){  
                uni.showModal({  
                    content: '是否删除本条信息?',  
                    success:(res) => {  
                        if (res.confirm) {  
                            this.newsitems[index1].data.splice(index2,1);  
                        }  
                    }  
                })  
            },  
            async changeTab(e) {  
                this.tabIndex = e.index;  
                const el = this.$refs[this.tabBars[e.index].id + e.index][0]  
                let elSize = await this.getElSize(el);  
                if (elSize.left + elSize.width > 750) {  
                    let index = e.index - 4;  
                    let newEl = this.$refs[this.tabBars[index].id + index][0]  
                    dom.scrollToElement(newEl, {});  
                    return;  
                }  
                if (elSize.left < 0) {  
                    dom.scrollToElement(el, {});  
                }  
            },  
            getElSize(el) { //得到元素的size  
                return new Promise((res, rej) => {  
                    const result = dom.getComponentRect(el, option => {  
                        res(option.size);  
                    })  
                })  
            },  
            createnewList() {  
                let ary = [];  
                for (let i = 0, length = this.tabBars.length; i < length; i++) {  
                    this.shows.add({loadingText: "加载更多...",  
                            data: []});  
                    this.loadShows(i)  

                }  
            }  
        }  
    }  
</script>  

<style>  
    .tab-bar-item {  
        width: 150px;  
        height: 100px;  
        flex-direction: column;  
        align-items: center;  
        justify-content: center;  
    }  

    .tab-bar-title {  
        height: 100px;  
        line-height: 100px;  
        font-size: 30px;  
        color: #555;  
    }  

    .active {  
        color: #007AFF;  
    }  

    .loadmore {  
        height: 70px;  
        width: 750px;  
        flex-direction: column;  
        justify-content: center;  
    }  

    .loadmore-text {  
        font-size: 30px;  
        text-align: center;  
        color: #999999;  
    }  

    .refresh {  
        width: 750px;  
        height: 70px;  
        flex-direction: row;  
        align-items: center;  
        justify-content: center;  
    }  
    .refresh-text{  
        text-align: center;  
        font-size: 28px;  
        color: #999999;  
    }  
</style>
2018-10-30 11:28 负责人:无 分享
已邀请:
2***@qq.com

2***@qq.com

解決了吗,兄弟,遇到一样得问题。

1***@qq.com

1***@qq.com

解决了吗兄弟,我也一样

  • 2***@qq.com

    解决了需要写在延时器里面

    2018-12-05 14:09

1***@qq.com

1***@qq.com

我报这个错是因为,我用到了同步storage,但是用了异步的storage就OJBK了,

阿哇

阿哇

部分uniAPI需要设置延迟,如:

setTimeout(() => {  
            uni.getSystemInfo(  
                {  
                    success: function(res) {  
                        t.height = res.statusBarHeight;  
                    }  
                },  
                1  
            );  
        });
虫雪浓

虫雪浓 - 热爱生活,热爱编程

请提供一个可复现问题,简单的demo吧,我自己写了一个 带参数打开 nvue的例子,并没有复现你的问题

  • h***@qq.com

    请问如果nvue是在底部JSON配置出来的TAB里面,另一个页面vue比如是登录页面也是在另一个TAB里面,如果vue页面登录了。如何回到nvue那TAB? vue有报错:Cannot read property '$getAppWebview' of undefined;如果vue页面不是TAB页面那就正常的。或者有什么方法可以使nvue TAB打开时自动执行获取新数据的动作。谢谢大神。

    2019-03-16 21:44

ThorUI_echo

ThorUI_echo - 开源项目: https://thorui.cn/doc

nvue页面所有uni api全部失效,执行就会提示launch webview id is not ready,延时也无效

n***@qq.com

n***@qq.com

我发现 id 不能数字 , 如果 ID xxx1 xxx2 这样的话 不会报错

h***@qq.com

h***@qq.com

顺便问一下你们这个有么有遇到这个问题,如果上拉加载,只加载一次,然后下拉刷新,再上拉的时候,页面到底部就再也不会触发加载更多了。

如果一开始就往上拉,加载更多,在继续往上拉,再第二次加载更多,在往下拉,刷新。再往上拉,页面能正常加载更多。

意思就是,必须要上拉加载更多触发2次或者2次以上,再下拉刷新的话,继续上拉功能才正常,如果一开始只触发加载更多一次,就下拉刷新,再滚动到底部,就不会触发加载更多了。感觉是底层的问题。个人很难去修复啊。官方也没有说明一下怎么处理。

Trust

Trust - 少说废话

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