【发布时间】:2021-02-17 04:33:30
【问题描述】:
我正在尝试在我的 React 网站中使用 Google AdSense 实现一个简单的横幅广告。我使用了 create-react-app。
我创建了一个包装横幅的组件:
import React, { Component } from 'react';
class AdBanner extends Component {
componentDidMount () {
(window.adsbygoogle = window.adsbygoogle || []).push({});
console.log('DID IT!!');
}
render () {
return (
<ins className="adsbygoogle"
style={{ display: "block"}}
data-ad-format="fluid"
data-ad-layout-key="-fb+5w+4e-db+86"
data-ad-client="ca-pub-xxxxxxxxxxxxx"
data-ad-slot="xxxxxxxxxx">
</ins>
);
}
}
export default AdBanner;
我在 index.html 文件的 <head> 标记中添加了以下脚本
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
## 问题## 广告没有以任何方式显示!编译器正常,浏览器在控制台中没有给出任何消息(除了“DID IT!”。我两天前在控制台中创建了广告。
我也尝试过停用 React 严格模式。
谢谢ssss
【问题讨论】:
-
您必须添加计费和付款方式。如果您仍有疑问,请检查此 - support.google.com/google-ads/answer/2375433