yoyojs
yoyojs

Reputation: 1783

external javascript snippets on nuxt js

I want to add a snippet i get from booking.com in my nuxt page, the script looks like that :

<ins class="bookingaff" data-aid="" data-target_aid="" data-prod="map" data-width="100%" data-height="590" data-lang="ualng" data-dest_id="0" data-dest_type="landmark" data-latitude="{{ data.lat }}" data-longitude="{{ data.lng}}" data-mwhsb="0">
            <!-- Anything inside will go away once widget is loaded. -->
            <a href="//www.booking.com?aid=**">Booking.com</a>
</ins>
        <script type="text/javascript">
            (function(d, sc, u) {
                var s = d.createElement(sc), p = d.getElementsByTagName(sc)[0];
                s.type = 'text/javascript';
                s.async = true;
                s.src = u + '?v=' + (+new Date());
                p.parentNode.insertBefore(s,p);
            })(document, 'script', '//aff.bstatic.com/static/affiliate_base/js/flexiproduct.js');
        </script>

So there is this tag where i have to pass the latitude and the longitude of my point to get the hotels near from. Does anyone knows how to insert this kind of external snippet in nuxt ?

Upvotes: 0

Views: 804

Answers (1)

Jair Reina
Jair Reina

Reputation: 2915

Third party code can be included using a custom Nuxt plugin. The plugins are included in your app before instantiating the root Vue app. See the documentation here: https://nuxtjs.org/guide/plugins/

Upvotes: 1

Related Questions