nodejs 接收参数,js前端传参方法
2024-09-18 16:55:19
nodejs
// 接口:查询检测结果 req.query接收
router.get('/getDetectionResult', (req, res) => {
console.log(req.query.id);
const conn = mysql.createConnection(models.mysql)
const sql = ` select ci.Name,pc.Result from product p
left join productcheckresult pc on pc.ProductId= p.Id
left join configurationplan plan on plan.Id=pc.ConfigurationPlanId
left join checkitem ci on ci.Id=plan.CheckItemId
where p.Id='${req.query.id}'`
conn.query(sql, function (err, result) {
if(err){
console.log(err)
}
if(result){
jsonWrite(res, result)
}
})
conn.end()
})
前端js
// 接口:查询返回结果 {params:{id:this.imagesDataList.id}} 传参
getDetectionResult() {
this.$http
.get("http://localhost:3000/api/sysuser/getDetectionResult",{params:{id:this.imagesDataList.id}},{
emulateJSON:true
})
.then((response) => { if (response.status == 200) { this.detectionResult = response.data;
// console.log(this.detectionResult);
} else {
console.log(response);
}
})
.catch((error) => {
console.log(error);
});
},
最新文章
- 排序之----插入排序(C#实现)
- Mono自定义图片按钮
- 后端码农谈前端(CSS篇)第六课:盒子模型
- 浩瀚技术助力批发零售商户实现PDA移动POS打印扫描进销存信息化管理
- math方法
- 共享内存shared pool (3):Library cache
- plsql programming 16 动态SQL和动态PLSQL
- Activiti源码浅析:Activiti的活动授权机制
- WPF拖动绘制
- 控制用户的访问之权限、角色【weber出品必属精品】
- paip.oracle query export to insert sql
- python 标准模块shlex
- ODM、JDM、OEM概念
- 环境部署(七):linux下Jenkins+Git+JDK持续集成
- 一个linux bbr存在的调用顺序bug
- java 大数处理
- css3实现漂亮的倒影效果
- NetCore+Dapper WebApi架构搭建(四):仓储的依赖注入
- Java之对象构造过程
- 通过pd.to_sql()将DataFrame写入Mysql