lyg
lyg
  • 发布:2018-09-05 14:24
  • 更新:2021-09-22 23:53
  • 阅读:16348

uni.navigateTo跳转页面传参失败,是什么情况?

分类:uni-app

index.vue代码:

<template>  

    <view>  
        <view>  
            <button @tap="test">test</button>  
            <navigator url="condition?id=navigate" hover-class="navigator-hover">  
                    <button type="default">跳转到新页面</button>  
            </navigator>  
        </view>  

    </view>  
</template>  

<script>  

    export default {  
        methods: {  
            test: function (e) {  
                console.log("aaaaaaa");  
                uni.navigateTo({  
                    url:'condition?id=1&name=2'  
                })  
            }  
        }  
    }  
</script>

被跳转页condition.vue代码

<script>  
    export default {  
        data:{},  
        onLoad: function (option) {   
            console.log(option.id);  
        }  
    }  
</script>

控制台打印结果

14:20:58.533  undefined at pages/index/condition.vue:5

参考文档

http://uniapp.dcloud.io/api/ui/navigate?id=redirectto

附言

如果把 navigateTo 换成 redirectTo 传参就可以成功了

2018-09-05 14:24 负责人:无 分享
已邀请:
Neil_HL

Neil_HL

1.condition页面是tab页面,只能用switchTab跳转tab页面(目前你能使用navigateTo进行跳转是我们还没做限制,下版会限制这样的跳转方式);

  1. switchTab跳转不支持传递参数。
  • lyg (作者)

    也就是说,如果不把页面配置到tabBar里面,navigateTo传参就没问题了吧

    2018-09-06 15:52

  • Neil_HL

    回复 lyg:是的

    2018-09-06 15:55

Trust

Trust - 少说废话

上传一下可以重现问题的 demo,方便测试定位问题,感谢配合。

  • lyg (作者)

    附件已经上传了,我又弄了个demo,测试是可以的,但是唯一不同的地方是pages.json中增加了tabBar的配置

    2018-09-05 18:15

lyg

lyg (作者)

项目附件,其实特别的地方就是增加了tabBar,

以下是pages.json代码

{  
    "pages": [{  
        "path": "pages/index/index",  
        "style": {  
            "enablePullDownRefresh": true  
        }  
    }, {  
        "path": "pages/index/condition",  
        "style": {  
            "enablePullDownRefresh": true  
        }  
    }],  
    "globalStyle": {  
        //"navigationStyle": "custom",  
        "navigationBarTextStyle": "black",  
        "navigationBarTitleText": "uni-app",  
        "navigationBarBackgroundColor": "#F8F8F8",  
        "backgroundColor": "#F8F8F8"  
    },  
    "tabBar": {  
        "color": "#7A7E83",  
        "selectedColor": "#3cc51f",  
        "borderStyle": "black",  
        "backgroundColor": "#ffffff",  
        "list": [{  
            "pagePath": "pages/index/index",  
            "text": "equan"  
        }, {  
            "pagePath": "pages/index/condition",  
            "text": "condition"  
        }]  
    }  
}
a***@ddi-sh.com

a***@ddi-sh.com

投诉,严重投诉,这种bug。。。天理不R

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