Home >Web Front-end >uni-app >How to jump to page and pass value in uniapp
Uniapp jump page value transfer method: first pass the id to the click event; then write the method in Methods, the code is [uni.navigateTo({url:'opportunity-form?id=' id}) ]; Finally, receive parameters on the details page.
The operating environment of this tutorial: windows7 system, uni-app2.5.1 version. This method is suitable for all brands of computers.
Recommended (free): uni-app development tutorial
Method of passing value in uniapp jump page:
First Introducing the most original jump method, similar to the a tag in HTML, but in uniapp you need to replace the a tag with
35d5f9ed482a4300281a6fe02425899e... 9a67f2adf02d82de7f8f0475590779aa
Let’s focus on the method of jumping and passing values
1. Pass the id to the click event
<view @tap="toOpportnity(item.id)">转商机</view>;
2. Methods Chinese writing method
toOpportnity(id){ uni.navigateTo({ //点击跳转的方法 url:'opportunity-form?id='+id //需要跳转的页面路径,使用问号进行id的传值,然后再拼接一个要传入的id//对象传参方式 url:'../../pages/disabled/subsidie?listObj=' + encodeURIComponent(JSON.stringify(obj)) }) }
3. Details page receiving parameters
写一个onLoad函数 onLoad(options){ //传入的参数名称,可自行修改 // console.log(options); 查看传入的id值 对象传参的接收方法 //this.leadobj(上个页面传过来的对象名称,即?后面的那个名称) = JSON.parse(decodeURIComponent(options.leadobj)); }
Receiving of a single parameter, here we use id to introduce
First we need to assign the passed id
Request interface, the url address of the interface should be followed by the passed id [/${this.id}/]
The complete steps are as follows:
onLoad(options){ this.id = options.id; console.log('传过来的id值为:' + options.id); let that = this uni.request({ url:`${this.$serverUrl}/opportunity/${this.id}/`, header:{ 'Authorization': this.uerInfo.token }, success(res){ console.log(res) that.opportunity = res.data; } }) }
Related free learning recommendations: php programming (video)
The above is the detailed content of How to jump to page and pass value in uniapp. For more information, please follow other related articles on the PHP Chinese website!