uni.navigateTo(OBJECT)

uni.navigateBack可以返回到原页面。 OBJECT参数说明 示例

  1. //在起始页面跳转到test.vue页面并传递参数uni.navigateTo({ url: 'test?id=1&name=uniapp'});
  1. // 在test.vue页面接受参数export default { onLoad: function (option) { //option为object类型,会序列化上个页面传递的参数 console.log(option.id); //打印出上个页面传递的参数。 console.log(option.name); //打印出上个页面传递的参数。 }}

窗体通信、全局变量,或encodeURIComponent等多种方式解决,如下为encodeURIComponent示例。

  1. <navigator :url="'/pages/test/test?item='+ encodeURIComponent(JSON.stringify(item))"></navigator>
  1. // 在test.vue页面接受参数onLoad: function (option) { const item = JSON.parse(decodeURIComponent(option.item));}

注意:

  • plus.runtime.openURL或web-view组件;H5平台使用 window.open;小程序平台使用web-view组件(url需在小程序的联网白名单中)。在hello uni-app中有个组件ulink.vue已对多端进行封装,可参考。