学堂 学堂 学堂公众号手机端

在uniapp中,可以通过使用uni.navigateTo或uni.redirectTo方法来实现内容跳转

lewis 1年前 (2024-03-09) 阅读数 2 #技术

在uniapp中,可以通过使用uni.navigateTo或uni.redirectTo方法来实现内容跳转。这两个方法都会跳转到应用中的指定页面,并可以传递参数给目标页面。

  1. 使用uni.navigateTo方法实现内容跳转:
uni.navigateTo({ url:'pages/targetPage', success:function(res){ console.log(res) }, fail:function(err){ console.log(err) } })
  • 使用uni.redirectTo方法实现内容跳转:
  • uni.redirectTo({ url:'pages/targetPage', success:function(res){ console.log(res) }, fail:function(err){ console.log(err) } })

    在目标页面中,可以通过uni.getStorageSync或uni.getStorage方法获取传递过来的参数:

    //目标页面中获取参数 letparams=uni.getStorageSync('key') console.log(params) 或者 uni.getStorage({ key:'key', success:function(res){ console.log(res.data) }, fail:function(err){ console.log(err) } })

    通过以上方法,可以实现在uniapp中使用接口实现内容跳转,并且传递参数给目标页面。


    版权声明

    本文仅代表作者观点,不代表博信信息网立场。

    热门