【发布时间】:2020-07-07 18:40:59
【问题描述】:
我有一个反应打字稿项目。在我的 result 数组中,我有一个返回 url 的值。该网址包含 /Items(142)/ 。我想检索项目 ID 并将其存储在变量中/
我知道我可以做类似result.data.odata.editLink.search() 的事情,但里面的数字总是在变化。我该怎么做。
这是我目前拥有的。
for (let file of this.state.requestFiles) {
r.item.attachmentFiles.add(file.name, file).then(result => {
console.log(result);
console.log(result.data.odata.editLink);
let requestID = //Here is where I want to put the ID fround in the url
})
}
这是我的结果控制台:
{data: {…}, file: AttachmentFile}
data:
FileName: "Capture-problem.PNG"
FileNameAsPath: {DecodedUrl: "Capture-problem.PNG"}
ServerRelativePath: {DecodedUrl: "/sites/Test/Attachments/142/Capture-problem.PNG"}
ServerRelativeUrl: "/sites/TestAttachments/142/Capture-problem.PNG"
odata.editLink: "Web/Lists(guid'24b9fe8b-3b87-44e4-b185-706d543d9567')/Items(142)/AttachmentFiles('Capture-problem.PNG')"
odata.type: "SP.Attachment"
odata.editLink 的 ID 位于()
【问题讨论】:
标签: javascript reactjs typescript for-loop