gpt4 book ai didi

reactjs - 如何在 react.js 中使用 google map iframe 嵌入代码

转载 作者:行者123 更新时间:2023-12-05 08:30:55 27 4
gpt4 key购买 nike

我正在使用 react.js。我必须在我的联系我们页面上显示 map ,所以我添加了从谷歌地图获得的 iframe 嵌入代码。我正在使用下面的代码。我没有使用任何 API。

import React from 'react';

const AddressMap=()=>{
return(
<div className="google-map-code">
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d15282225.79979123!2d73.7250245393691!3d20.750301298393563!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x30635ff06b92b791%3A0xd78c4fa1854213a6!2sIndia!5e0!3m2!1sen!2sin!4v1587818542745!5m2!1sen!2sin" width="600" height="450" frameborder="0" style="border:0;" allowfullscreen="" aria-hidden="false" tabindex="0"></iframe>

</div>

);
}
export{AddressMap}

我的页面出现错误

Error: The style prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + 'em'}} when using JSX.

你能帮我解决这个问题吗?

最佳答案

在 React 风格中需要一个对象。例如:style={{border:0}}

import React from 'react';
const AddressMap=()=>{
return (
<div className="google-map-code">
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d15282225.79979123!2d73.7250245393691!3d20.750301298393563!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x30635ff06b92b791%3A0xd78c4fa1854213a6!2sIndia!5e0!3m2!1sen!2sin!4v1587818542745!5m2!1sen!2sin" width="600" height="450" frameborder="0" style={{border:0}} allowfullscreen="" aria-hidden="false" tabindex="0"></iframe>
</div>
);
}
export{AddressMap}

关于reactjs - 如何在 react.js 中使用 google map iframe 嵌入代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61425949/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com