In uni-app, the following methods can be used to realize page jump and pass object parameters: 1. Before jumping, convert the object parameters to be passed into JSON strings, then encode them with encodeURIComponent, and splicing them after the url. // The path of the page to be redirected const url = '/pages/detail/detail'; // The object parameter to be passed const obj = { id: 123, name: 'test' }; // Convert the object parameter to JSON String, and use encodeURIComponent to encode const params = encodeURIComponent(JSON.stringify(obj)); // Jump to the page and pass object parameters uni.navigateTo({ url: `${url}?params=${params}` } ); 2. On the redirected page, get the passed object parameter through `onLoad` event, use decodeURIComponent to decode, and then convert it into an object. // detail.vue export default { data() { return { obj: null } }, onLoad(options) { // Obtain the passed object parameters, use decodeURIComponent to decode them, and convert them to objects if ('params' in options) { this.obj = JSON.parse(decodeURIComponent(options.params)); } } } This can be achieved in uni -The need to jump pages and pass object parameters in the app.
How does uniapp pass the jump page and pass object parameters
Guess you like
Origin blog.csdn.net/weixin_60415789/article/details/130266300
Recommended
Ranking