typescript - 如何传递 ID 以从资产文件夹中读取 Json
问题描述
id = localStorage.getItem('currentUser')
this.http.get('./assets/id/profiles/admin.json')
.subscribe(result => {
this.profile = result.json();
});
使用该 id 从本地存储中获取 id 值,尝试读取 json。如何传递该 id 来读取特定的 json。
解决方案
这是您的方案的解决方案,
let id = localStorage.getItem('currentUser');
this.http.get(`assets/${id}/profiles/admin.json`)
.subscribe(result=> {
this.profile = result.json();
//do some stuff
})
对我来说很完美。让我们试试这个,让我知道。
推荐阅读
- scala - 对象注入不是包 com.google 的成员
- c++ - glm::rotate 导致纹理膨胀
- php - 使用 PHP CURLFile 上传 Dropbox
- erlang - 如何通过引用将元组列表传递给 Erlang 中的多个线程?
- python - 如何在函数内部无限循环
- git - 为什么 git rebase 在新的分支特定文件上标记冲突
- ionic4 - 在 Ionic4 应用程序中嵌入 Vimeo 视频的正确方法是什么?
- python-3.x - 使用嵌套的while循环删除字符串中的重复项
- docker - Docker Windows 本地注册表:收到意外的 HTTP 状态:500 内部服务器错误
- python - 打包我的python代码后,包含文件中的打印语句没有显示