navigator
页面链接。 属性说明 open-type 有效值 注意
<navigator>的子节点背景色应为透明色。**<navigator>示例<template> <view> <view class="page-body"> <view class="btn-area"> <navigator url="navigate/navigate?title=navigate" hover-class="navigator-hover"> <button type="default">跳转到新页面</button> </navigator> <navigator url="redirect/redirect?title=redirect" redirect hover-class="other-navigator-hover"> <button type="default">在当前页打开</button> </navigator> </view> </view> </view></template>
窗体通信、全局变量,或// navigate.vue页面接受参数export default { onLoad: function (option) { //option为object类型,会序列化上个页面传递的参数 console.log(option.id); //打印出上个页面传递的参数。 console.log(option.name); //打印出上个页面传递的参数。 }}
encodeURIComponent等多种方式解决,如下为encodeURIComponent示例。<navigator :url="'/pages/navigate/navigate?item='+ encodeURIComponent(JSON.stringify(item))"></navigator>
注意 -// navigate.vue页面接受参数onLoad: function (option) {const item = JSON.parse(decodeURIComponent(option.item));}
在 GitHub 上编辑此页面!
