How to add Google Ads Manager Ads units (Banners) using NuxtJs/VueJs frameworks?

I have this Ads unit


<script type="text/javascript">
google_ad_client = "ca-pub-2158343444694791";/* AD7 */
google_ad_slot = "AD7";
google_ad_width = 300;
google_ad_height = 250;
</script>
<script type="text/javascript" src="//pagead2.googlesyndication.com/pagead/show_ads.js"></script>

I would like to place a script on my website’s homepage and show the banner 5 times in deffrent places.

The website is developed using NodeJs, NuxtJs3, and VueJs3 with both SSR and SPA.

However, as you know, I can not place script tags inside the vuejs template.

Can you please guide me on how to render this correctly?
So far, I have attempted the following:

**Tempalte **

<div class="my_div"></div>

Javascript


nuxt.hook("page:loading:end", () => {
  loaderLoading.value = false
  setTimeout(() => {
    var div = document.querySelector('.my_div');

    // Create a script element
    var script = document.createElement('script');

    // Set the type attribute
    script.type = 'text/javascript';

    // Set the source (src) attribute
    script.src = '//pagead2.googlesyndication.com/pagead/show_ads.js';

    // Create an inline script element for the ad parameters
    var inlineScript = document.createElement('script');
    inlineScript.type = 'text/javascript';
    inlineScript.innerHTML = `
    google_ad_client = "ca-pub-2158343444694791";
    /* AD7 */
    google_ad_slot = "AD7";
    google_ad_width = 300;
    google_ad_height = 250;
`;
    console.log("test")
    // Append the inline script to the div
    div.appendChild(inlineScript);

    // Append the script to the div
    div.appendChild(script);

  }, 2000);
}) 

The problem i have a lot of console errors such as :

Uncaught TagError: adsbygoogle.push() error: Ad client is missing from the slot.
Uncaught TypeError: Cannot read properties of null (reading 'appendChild')
Unchecked runtime.lastError: The message port closed before a response was received.

Please advise on the correct placement of ad units. Is there a library that supports Google Ads Manager ad units? Please note that this is different from Google AdSense.

Regards