uni.navigateTo-页面传参 vue2

A页面跳转到B页面,传参过去

A页面method

 //点击进入明细
        toDetail() {
            console.log('click')
            let val = encodeURIComponent(JSON.stringify(this.detailData[0]))
            uni.navigateTo({
                url: "/pages/detail?data=" + val
            });
        }

B页面

<template>
    <view>
        <view>接收参数</view>
        <view>{{ data }}</view>

    </view>
</template>

<script>
export default {
    name: '',
    data() {
        return {
            data: []
        }
    },
    methods: {
        onLoad(option) {
            let a = JSON.parse(option.data);
            this.data = a;
        
        }
    }
}
</script>

<style scoped></style>
posted @ 2025-01-22 10:39  格林格林  阅读(47)  评论(0)    收藏  举报