这个问题在这里已有答案:
这可能听起来很简单,但我不能让它奏效。我有这个url到sharepoint列表中的项目:
https://tenant.sharepoint.com/sites/Demo2/Lists/AgreementDatabase/DispForm.aspx?ID=1
我想使用react渲染它,但ID部分不起作用:
render: (item: IList) => {
return (<a href="https://hernancompany.sharepoint.com/sites/Demo2/Lists/AgreementDatabase/DispForm.aspx?ID=${item.Id}">{item.Title}</a>);
}
相反,对于ID = 1,它呈现ID = $ {item.Id}这是正确的语法?
编辑:你的意思是这样的?:
你的意思是这样的:
return (<a href=`https://hernancompany.sharepoint.com/sites/Demo2/Lists/AgreementDatabase/DispForm.aspx?ID=${item.Id}`>{item.Title}</a>);
因为那没用。
最好的问候Americo
您可以使用反引号方法:{`url / path / goes / here $ {variableCanGoHere}`}
render: (item: IList) => {
return (<a href={`https://hernancompany.sharepoint.com/sites/Demo2/Lists/AgreementDatabase/DispForm.aspx?ID=${item.Id}`}>{item.Title}</a>);
}
尝试在计算机上的Esc按钮附近使用反引号(backtics?)。
`https://hernancompany.sharepoint.com/sites/Demo2/Lists/AgreementDatabase/DispForm.aspx?ID=${item.Id}`
反引号是使这项工作成功的原因。这是我相信的一个新功能。