1.传值页面

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<script>
export default {
data() {
return {}
},
methods: {
navBar() {
let obj = {
name: '阿清',
age: 10,
sex: '男'
};
// 加密传递的对象数据
let item = encodeURIComponent(JSON.stringify(obj))
uni.navigateTo({
url: '/pages/navbar/navbar?item=' + item
})
}
}
}
</script>

2.接收的页面

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<script>
export default {
data() {
return {
userObj: {}
}
},
onLoad: function(option) {
// decodeURIComponent 解密传过来的对象字符串
const item = JSON.parse(decodeURIComponent(option.item));
this.userObj = item
}
}
</script>