uniapp uni.navigateTo传递(对象类型)参数

最近在做微信小程序,用的是uniapp开发的,自己记录一下,也和大家分享一下

1、字符串拼接,传递单个属性值

 index页面传递:


   
   
  1. data( ){
  2. return{
  3. companyOrgId: 1
  4. }
  5. }
  6. methods:{
  7. goRegister( ) {
  8. uni. navigateTo({
  9. url: `./registerDetail?companyOrgId=${this.companyOrgId}`
  10. });
  11. },
  12. }

home页面接收:


   
   
  1. onLoad( options) {
  2. this. info. companyOrgId = options. companyOrgId;
  3. console. log(options. companyOrgId);
  4. },

2、整个对象的传递

 index页面传递:


   
   
  1. data( ){
  2. return{
  3. info: {
  4. companyOrgId: '',
  5. sex: 0,
  6. surname: '',
  7. firstname: '',
  8. email: '',
  9. phone: '',
  10. phoneAreaCode: '+852',
  11. password: '',
  12. passwordTwo: '',
  13. birthYear: 'YY',
  14. birthMonth: 'MM',
  15. birthDay: 'DD'
  16. },
  17. }
  18. }
  19. methods:{
  20. goRegisterCode( ) {
  21. console. log( 'info', this. info);
  22. uni. navigateTo({
  23. url: './registerCode?info=' + encodeURIComponent( JSON. stringify( this. info))
  24. });
  25. },
  26. }

home页面接收:


   
   
  1. onLoad( options){
  2. let userInfo = JSON. parse( decodeURIComponent(options. info));
  3. console. log( 'userInfo', userInfo);
  4. }

3、多个对象的传递

 index页面传递:


   
   
  1. uni. navigateTo({
  2. url: '/pages/setSeal/index?seal=' + encodeURIComponent( JSON. stringify(seal)) + '&cStorageModel' + encodeURIComponent( JSON. stringify(cStorageModel))
  3. });

home页面接收:


   
   
  1. onLoad( option){
  2. this. pageModel. sealAuth = JSON. parse( decodeURIComponent(option. sealAuth));
  3. this. pageModel. cStorageModel = JSON. parse( decodeURIComponent(option. cStorageModel));
  4. },

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值