使用uView开发app,页面跳转传参数及在目标页面接收

javascript / 2024年01月17日 19时39分 / 372人浏览

使用uView开发app,页面跳转传参数及在目标页面接收参数。目标页面在 onLoad ⽅法中直接拿就⾏,options.传递参数的名字

页面A

 

export default {
    props:{
        list:{
            type:Array,
            default:[]
        }
    },
    data() {
        return {

        }
    },
    //第一次加载
    created(e) {
       
    },
    methods: {
		onJumpTo(id){
			 uni.$u.route({
				url:'/pages/index/info/info',
				params: {id: id}
			 })
		},
    }
}

目标页面B

 

		onLoad(options) {
	
			let httpData = {
			    token: this.userInfo.userinfo.token, 
			 	id: options.id,
							
			}
			let params = {params: httpData}
			
					
			// api集中管理使用
			getPhInfo(params).then((res) => {
				console.log('phinfo:',res)
				this.$data.phinfo = res;
			
					
					
			}).catch((err) =>{
				
				uni.showToast({
						title: err.msg,
						icon: 'none',				
				});
				
			})
		},