【发布时间】:2018-12-01 15:34:33
【问题描述】:
我正在尝试使用 javascript 上的 GET 方法从 URL 获取数据,
fetch('/api/staffattendance/{makedate}')
.then(res => res.json())
.then(res => {
//this.staffs = res.data;
console.log(res.data);
})
.catch(err => console.log(err));
如何在此处传递变量
fetch('/api/staffattendance/{makedate}')
像这样
提前致谢,
【问题讨论】:
-
你搜索了一下?也许
`my_string${my_variable}`是您正在寻找的。或字符串连接。有很多可用的解决方案并且有据可查 -
看起来你正在尝试使用
Template Literals
标签: javascript fetch fetch-api