列表页面传递一个id给对应的详情页面(做项目时的简单总结)
来源:互联网 发布:真空上街 知乎 编辑:程序博客网 时间:2024/06/10 00:29
我们经常会遇见一个列表页面,我们需要点击到它的详情页面去看一看。
这时就会用到传递一个id,给详情页面。
//这是列表页面的函数
//点击列表页面的每一项时,跳到对应的详情页面//一般我们传的都是id//点击事件,跳转到详情页面itemClicklEvent(index) { //console.log('跳转到列表详情页面'); //得到id,这个很简单 let id = this.state.contentList[index].id; //console.log('type',type); //跳转到详情页面去 this.props.history.push(`/distribute_detail/${id}`);}
详情页面
//首先需要得到idcomponentDidMount(){ /** * @newsDetailData 对请求到对应id数据进行处理 * @param{} 参数uri=admin/alliance/messages/${id} * */ let id = this.props.match.params.id; //console.log(id); newsDetailData(`uri=admin/alliance/messages/{id}`).then(res => { if(res.status !== 200){ console.log('您目前无法获取消息详情页的数据'); }else{ return res.json() } }).then(data=>{ console.log('newsDetailData',data); this.setState({ machine_code: data.sn, time: data.createdTime, location: data.address, content: data.content, description: data.description }) }).catch(e=>{ console.log('数据请求失败!'); })}
路由配置
这里面是通知页面和通知详情页面
报告页面和报告详情页面
<Router history={ history } > <div style={{ width: '100%',height: '100%'}}> <Route exact path="/" component={ Login } /> <Route path="/home" component={ Home } /> <Route path="/billitemized" component={ billItemiezd } /> <Route path="/calender" component={ Calender } /> <Route path="/billing_report" component={ Billing } /> <Route path="/income_detail" component={ Income } /> <Route path="/report_detail/:id" component={ Report } /> <Route path="/news_inform" component={ Inform } /> <Route path="/news_detail/:id" component={ News } /> <Route path="/no_found" component={ NoFound } /> </div></Router>
主要是这种写法:
<Route path="news_inform" component={ Inform }/><Route path="news_detail/:id" component={ News }/>
阅读全文
0 0
- 列表页面传递一个id给对应的详情页面(做项目时的简单总结)
- 10、父页面传递参数给子页面,然后进行对应的数据处理
- bootstrap入门-做一个简单的页面
- Jsp动态网站初步项目 --简单的商品浏览页面 (商品详情页面details.jsp)
- JSP页面结合Struts2如何传递复选框对应的id数组到后台action中
- 获得页面地址栏传递来的id
- 简单的新闻列表页面
- jquery制作一个简单的loading--页面参数传递
- web页面的列表总结
- js获取页面加载过程做一个简单的loading
- 如何做一个简单的Guide(引导)页面
- 使用JDBC做一个简单的登录,注册页面!
- ID在一个页面的唯一性
- Android listView中点击item或Item中控件跳转对应的详情页面的实现(商品详情查看)
- 一个包含上传控件的用户控件把信息传递给包含页面的方法
- 一个简单的WAP页面
- 一个简单的struts页面
- 一个简单的JSP页面
- NoSuchBeanDefinitionException
- Malloc(),realloc(),calloc(),free()的用法及含义
- com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Query was empty异常原因?
- *HMK 1 for NOIP (130/300)
- 使用pyinstaller将python脚本转换成exe可执行文件
- 列表页面传递一个id给对应的详情页面(做项目时的简单总结)
- Linux静态库和动态库
- 企业实战之Spring拦截器《解决跨域问题》
- 从c语言中常用变量的生命周期,作用域,默认值,内存区域及链接属性
- vue.js 表单控件 输入绑定 v-model的使用
- vnc, vncserver, ssh的locale问题
- 大型网站技术架构
- 升级OSX High Sierra 10.13遇到一些问题及解决方法
- linux socket网络编程实例