传参,点击事件,传递id进入
<template>
<view class="out">
<view class="row" v-for ="(item,index) in indexData" :key = "item.id" @click="clickItem(item.id)">
<view class="title">{{item.na}}</view>
<view class="content">{{item.desc}}</view>
<view class="content">{{item.id}}</view>
</view>
</view>
</template>
跳转时候,传递参数
methods: {
//点击跳转详情
clickItem(e){
console.log(e)
//return;
uni.navigateTo({
url:"/pages/demo3/demo3?id="+e
})
}
}
在新页面接收传递过来的参数
onLoad(e) {
console.log(e);
this.id=e.id;
this.getIndexData();
},
封装的网络请求添加数据加载中
import base from "./base";
export default (url,data={},method='GET')=>{
return new Promise((resolve,reject) => {
uni.showLoading({
title:"数据加载中...",
mask:true
}),
uni.request({
url:base.host+url, //仅为示例,并非真实接口地址。小程序请求
// url,
data,
method,
header: {
// 'Content-Typee': 'application/x-www-form-urlencoded',
'content-type': 'application/x-www-form-urlencoded;charset=utf-8'
//'Content-Type': 'application/json'
},
success: (res) => {
resolve(res.data);
},
complete() {
uni.hideLoading()
},
fail:(err) => {
reject(err)
}
});
})
}
![在这里插入图片描述](https://img-blog.csdnimg.cn/direct/9c040eb036c64b959bc914a837342fad.gif#pic_center)