【问题标题】:ReactJS and Adsense Responsive AdsReactJS 和 Adsense 响应式广告
【发布时间】:2018-01-24 16:51:48
【问题描述】:

我与 ReactJS 中的 Adsense 广告斗争了几个小时:

这是我的代码:

export default class AdJobDetail extends React.Component {
    componentDidMount() {
        (window.adsbygoogle = window.adsbygoogle || []).push({});
    }

    render() {
        return (
            <div className={style.container}>
                <ins className='adsbygoogle'
                    style={{ display: 'display:block' }}
                    data-ad-client="ca-pub-6591684000448474"
                    data-ad-slot="6458345829"
                    data-ad-format="auto" />
            </div>
        );
    }
}

(广告客户和广告位已更改)。

这是我使用的样式:

.container {
margin-top: 20px;
border: 1px solid $light-grey;
width: 200px;
height: 200px;
}

.ins {
width: 100%;
height: 100%;
}

我不断得到:

adsbygoogle.push() 错误:没有可用宽度=0 的槽大小

我的问题是:

  • 对我来说,宽度大于 0,为什么会出现此错误?
  • 会不会是脚本没有正确挂载?但是我的非响应式广告效果很好......

【问题讨论】:

  • 您的 css 将 &lt;ins /&gt; 标记作为类 .ins 将其更改为 ins 或 .adsbygoogle。

标签: reactjs adsense


【解决方案1】:

您可能需要对宽度使用绝对单位(例如 px),而不是百分比等相对宽度单位。

【讨论】:

    猜你喜欢
    • 2016-09-25
    • 1970-01-01
    • 2013-12-18
    • 1970-01-01
    • 2014-11-22
    • 2018-09-21
    • 2015-11-17
    • 2013-09-10
    • 2016-04-20
    相关资源
    最近更新 更多