uni-app使用uni.navigateTo傳遞對象參數(shù)示例代碼
更新時間:2023年11月16日 15:32:43 作者:Bonsoir777
最近在做微信小程序用的是uniapp開發(fā)的,自己記錄一下,也和大家分享一下,這篇文章主要給大家介紹了關(guān)于uni-app使用uni.navigateTo傳遞對象參數(shù)的相關(guān)資料,需要的朋友可以參考下
一、傳遞一般參數(shù)
const index = 1; uni.navigateTo({ url: `../address/address?key=${index}` })
二、傳遞對象參數(shù)
1.傳遞參數(shù)
// 跳轉(zhuǎn)到訂單詳情頁面 toOrder(item) { // console.log(item.hpv_id, 'hpv_id') uni.navigateTo({ url: '../hpvOrder-detail/hpvOrder-detail?key=' + encodeURIComponent(JSON.stringify(item)) }) }
2.接收參數(shù)
navigateTo進(jìn)行頁面?zhèn)鬟f參數(shù),在下一個頁面接收數(shù)據(jù),一般在在onLoad鉤子函數(shù)中獲取
onLoad(e) { this.detail = JSON.parse(decodeURIComponent(e.key)); console.log(this.detail) }
附:多個對象的傳遞
index頁面?zhèn)鬟f:
uni.navigateTo({ url: '/pages/setSeal/index?seal=' + encodeURIComponent(JSON.stringify(seal)) + '&cStorageModel' + encodeURIComponent(JSON.stringify(cStorageModel)) });
home頁面接收:
onLoad(option){ this.pageModel.sealAuth = JSON.parse(decodeURIComponent(option.sealAuth)); this.pageModel.cStorageModel = JSON.parse(decodeURIComponent(option.cStorageModel)); },
總結(jié)
到此這篇關(guān)于uni-app使用uni.navigateTo傳遞對象參數(shù)的文章就介紹到這了,更多相關(guān)uni.navigateTo傳遞對象參數(shù)內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
使用SpreadJS快速清除Excel中工作表保護(hù)密碼
這篇文章主要為大家介紹了使用SpreadJS快速清除Excel中工作表保護(hù)密碼方法詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-11-11