0👍
✅
Every time you call the AdSense
method it tries to append another script
tag to the head of the document. And like the error suggests, you should only have the google ads script only once.
So, first step would be to split this script tag creation part to a separate method and make sure it is only called once.
Secondly, for re-rendering the ad element, you could try giving it a key
attribute. And when you want the ads to be reloaded, increment the key to a new value.
<ins v-if="adsense" class="adsbygoogle" :key="id"></ins>
data() {
return {
id: 1;
}
},
watch: {
$route (to, from) {
if(to !== from) {
this.id++;
}
}
}
Source:stackexchange.com