Linux 拨号vps windows公众号手机端

uniapp怎么使用接口实现内容跳转

lewis 9年前 (2016-12-20) 阅读数 6 #程序编程
文章标签 uniapp

在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)
  }
})
  1. 使用uni.redirectTo方法实现内容跳转:
uni.redirectTo({
  url: 'pages/targetPage',
  success: function(res) {
    console.log(res)
  },
  fail: function(err) {
    console.log(err)
  }
})

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

// 目标页面中获取参数
let params = uni.getStorageSync('key')
console.log(params)

或者

uni.getStorage({
  key: 'key',
  success: function(res) {
    console.log(res.data)
  },
  fail: function(err) {
    console.log(err)
  }
})

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

版权声明

本文仅代表作者观点,不代表米安网络立场。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

热门