我在 React 中得到了电影的名称,一切看起来都很棒
{movie.name}/{movie.enname} ({years})
h1 (Knives Out/《利刃出鞘》(2019))/h1
。但 我无法在 https://example.com/movie/ 的 iframe 窗口中显示此名称{movie.name} 这是 iframe:<iframe src="https://example.com/movie/?imdb={movie.name}¬itle=1&cover=11" alt="{movie.imdb_id}" allowfullscreen width="50%" height="350" frameborder="0" scrolling="no"></iframe>
因此它仍然是 {movie.name} 和 {movie.imdb_id},而不是收到的名称 Knives Out。 如何解决?
最佳答案
变量名称被视为 iframe src 中的字符串
示例
<iframe src={`https://example.com/movie/?imdb=${movie.name}¬itle=1&cover=11`} alt={movie.imdb_id} allowfullscreen width="50%" height="350" frameborder="0" scrolling="no"></iframe>
或
<iframe src={"https://example.com/movie/?imdb="+movie.name+"¬itle=1&cover=11" } alt={movie.imdb_id} allowfullscreen width="50%" height="350" frameborder="0" scrolling="no"></iframe>
关于javascript - React如何在iframe中输出名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59404571/