GoodAr
GoodAr
  • 发布:2021-08-31 13:51
  • 更新:2021-09-02 10:32
  • 阅读:989

redirectTo / redirectTo 在跳转的时候,自动在url前面加上“/pages/index”,导致跳转失败

分类:uni-app

这是失败回调 ```{"errMsg":"redirectTo:fail page `/pages/index/pages/call/call"}

2021-08-31 13:51 负责人:无 分享
已邀请:
GoodAr

GoodAr (作者)

methods: {  
			async getDataById(params) {  
				await apiUtil.getData({  
					"code": params  
				}).then((result) => {  
					console.log(result);  
					if (result == undefined || result == null) {  
						uni.redirectTo({  
						 	url: "pages/call/call?query=" + encodeURIComponent(JSON.stringify(result)),  
						 	fail(err) {  
								console.log(err);  
							},  
						 	success() {  
								console.log("");  
						 	}  
						 })  
					} else {  
						uni.reLaunch({  
							url: "./pages/index/index"  
						})  
					}  
				}, (error) => {  
					uni.reLaunch({  
						url: "./pages/error/error"  
					})  
				})  
			}  
		}
  • DCloud_UNI_HT

    pages/call/call?query=" 前面加上 / 如果不加,就是你出现的这个问题 ,路径补全了


    2021-09-06 11:20

DCloud_UNI_HT

DCloud_UNI_HT

路径错误 ,应该使用 /pages/call/call 或者 ../call/call

  • GoodAr (作者)

    使用的是/pages/call/call 路径,但是运行后系统会自定加 /pages/index在前面,导致跳转失败,上面是打印的错误信息。我在在app.vue里面使用的跳转,试过网上的延迟也不行。


    2021-09-01 10:55

  • DCloud_UNI_HT

    回复 GoodAr: 贴一下代码


    2021-09-02 10:28

  • GoodAr (作者)

    回复 DCloud_UNI_HT: 代码在下面贴出来了,getDataById 是在app.vueonLaunch里面调用的。这种情况只出现在异步调用里


    2021-09-02 10:36

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