Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 反应:如何呈现url?_Reactjs_Url_Syntax - Fatal编程技术网

Reactjs 反应:如何呈现url?

Reactjs 反应:如何呈现url?,reactjs,url,syntax,Reactjs,Url,Syntax,这听起来可能很简单,但我不能让它工作。 我有指向sharepoint列表中某个项目的url: https://tenant.sharepoint.com/sites/Demo2/Lists/AgreementDatabase/DispForm.aspx?ID=1 我想使用react渲染它,但ID部分不起作用: render: (item: IList) => { return (<a href="https://hernancompany.sharepoint.com/si

这听起来可能很简单,但我不能让它工作。 我有指向sharepoint列表中某个项目的url:

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>);
  }
render:(项:IList)=>{
返回();
}
相反,对于ID=1它呈现ID=${item.ID} 这句话的正确语法是什么

编辑: 你是说像这样

你的意思是这样的:

return (<a href=`https://hernancompany.sharepoint.com/sites/Demo2/Lists/AgreementDatabase/DispForm.aspx?ID=${item.Id}`>{item.Title}</a>);
return();
因为那没用

致意 Americo

尝试在电脑Esc按钮附近使用backticks(backtics?)

`https://hernancompany.sharepoint.com/sites/Demo2/Lists/AgreementDatabase/DispForm.aspx?ID=${item.Id}`
背部抽搐是使这项工作的原因。我相信这是一个较新的功能

您可以使用backtick方法:{`url/path/goes/here${variableCanGoHere}`}

render:(项:IList)=>{
返回();
}

我已经更新了帖子,我不能在评论中写代码。ES2015(ES6)中引入了模板文字(backticks)。你可以使用backticks`code goes here`在评论中写代码。修改你的编辑,在初始backtick前面和最后backtickFWIW之后用大括号括起来,背景符号表示一个。
render: (item: IList) => {
    return (<a href={`https://hernancompany.sharepoint.com/sites/Demo2/Lists/AgreementDatabase/DispForm.aspx?ID=${item.Id}`}>{item.Title}</a>);
  }