您现在的位置是:首页 > 名人名句

uniapp怎么传跳转页面并传递对象参数

作者:胡椒时间:2024-04-17 16:29:35分类:名人名句

简介  文章浏览阅读7.3k次,点赞6次,收藏25次。2. 在跳转后的页面,通过`onLoad`事件获取传递的对象参数,并使用decodeURIComponent解码,然后转为对象。1. 在跳转前,将需要传递的对象参数转为JSON字符串,然后用encodeURICom

点击全文阅读

在uni-app中,实现页面跳转并传递对象参数,可以通过以下方法:1. 在跳转前,将需要传递的对象参数转为JSON字符串,然后用encodeURIComponent进行编码,拼接在url后面。// 要跳转的页面路径const url = '/pages/detail/detail';// 要传递的对象参数const obj = {  id: 123,  name: 'test'};// 将对象参数转为JSON字符串,并使用encodeURIComponent编码const params = encodeURIComponent(JSON.stringify(obj));// 跳转页面并传递对象参数uni.navigateTo({  url: `${url}?params=${params}`});2. 在跳转后的页面,通过`onLoad`事件获取传递的对象参数,并使用decodeURIComponent解码,然后转为对象。// detail.vueexport default {  data() {    return {      obj: null    }  },  onLoad(options) {    // 获取传递的对象参数,使用decodeURIComponent解码,并转为对象    if ('params' in options) {      this.obj = JSON.parse(decodeURIComponent(options.params));    }  }}这样就可以实现在uni-app中跳转页面并传递对象参数的需求。

点击全文阅读

郑重声明:

本站所有活动均为互联网所得,如有侵权请联系本站删除处理

我来说两句

fetch1("select plface from {$dbtbpre}enewspl_set limit 1"); $facer=explode("||",$r[plface]); $count=count($facer); $plface=''; $plfacereply=''; for($i=1;$i<$count-1;$i++) { $face=explode("##",$facer[$i]); $img = $public_r[newsurl].'e/data/face/'.$face[1]; $plface.='
  • '; $plfacereply.='
  • '; } $userpiclink = ''; $username = getcvar('mlusername'); $userid=getcvar('mluserid'); $rnd = getcvar('mlrnd'); if($username&&$userid&&$rnd){ $user_r = sys_ShowMemberInfo($userid,'ui.userpic'); $userpic=$user_r[userpic]?$user_r[userpic]:$public_r[newsurl].'e/extend/lgyPl/assets/nouserpic.gif'; $userpiclink = ''; $userlink=''.$username.''; } ?>
    连接失败,请检查您的网络!
    热门评论
    0人参与,0条评论
    正在载入评论列表...