我试过将admob添加到vuejs中,但是没有明确的代码说明如何将其与vue组件集成。我从网上查过,vueJs没有明确的admob解决方案。
<template> <div> how admob Banner showing here </div> </template>
<script>
const admob = require("nativescript-admob");
//import admob from 'nativescript-admob'
export default {
name:'AdsPage',
mounted() {
setTimeout(() => {
admob.createBanner({
// if this 'view' property is not set, the banner is overlayed on the current top most view
// view: ..,
testing: true, // set to false to get real banners
size: 550, // anything in admob.AD_SIZE, like admob.AD_SIZE.SMART_BANNER
androidBannerId: "ca-app-pub-3940256099942544/6300978111", // add your own
margins: {
// if both are set, top wins
//top: 10
bottom: 50
},
}).then(
function() {
console.log("admob createBanner done");
},
function(error) {
console.log("admob createBanner error: " + error);
}
)
},5000)
}
</script>
1条答案
按热度按时间ars1skjm1#
您是否尝试过构建应用程序,然后检查横幅是否显示在测试设备上?
对我来说,在Vue中,横幅没有显示,但当我在Xcode(iOS)中运行代码时,它工作得很完美。
还要确保自己有位置相对!