类型 函数 返回值 无 修订 版本 2024.3703 关键词 AdSense, Google Ads, Google AdSense, show 另请参阅 adSense.init() adSense.*
显示 AdSense 广告,您必须先调用 adSense.init()。 目前仅支持横幅广告。
adSense.show( adType, parameters )
字符串。 当前支持 "banner"
。
表。 包含指定广告类型附加参数的表 — 有关详细信息,请参阅下一节。
字符串。 广告位是在控制台>广告概览>按广告单元>“展示广告”下为横幅广告创建的。 在 html 代码中,这在键 data-ad-slot
下调用。
字符串。 支持的值为 "top"
(默认)或 "bottom"
。
[数字][api.type. Number]。 默认值为 100
,此值为像素单位 (px
)。
[数字][api.type. Number]。 默认值为设备全宽 (100%
),但设置的值以像素单位 (px
) 为单位。
local adSense = require( "plugin.adSense" ) -- AdSense Ads listener function local function adListener( event ) if ( event.phase == "init" ) then -- Successful initialization adSense.show("banner",{adSlot="xxxxxxxxx", height=150, position="bottom"}) end end -- Initialize Ad Sense adSense.init(adListener, {clientId="ca-pub-xxxxxxxxxxxxxxxx"} )