ktquez / vue-head

Manager the meta information of the head tag, a simple and easy way
MIT License
984 stars 73 forks source link

How to add raw script #90

Closed Stacey940 closed 4 years ago

Stacey940 commented 4 years ago

Hi,

I am getting script tags from other application to add on the landing based on event via api call. I need to insert those scripts in the head of my vue app. How should I go to achieve this ? Here is an example script tag received :

<script type="text/javascript">
    window.rconf = {"user_id": "hgdeoqel","event": "page_viewed"};
    (function() {var r = document.createElement("script"); r.type = "text/javascript"; r.async = true;
    r.src = "https://xxxxxxxx.com/t/t.js";
    r.onload = r.onreadystatechange = function() {var  rs = this.readyState; if (rs && rs != 'complete' && rs != 'loaded') return;
    };var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(r, s);})();
</script> 

Thanks!

troyshu commented 4 years ago

I had the same issue, and figured it out: use the inner field like in the title README example.

script: [
          {
                type: 'text/javascript',
                inner: `
                    <your javascript here>
                `,
                async: false,
                body: false 
          }
        ]
appinteractive commented 2 years ago

sadly that does not work at all :(

script: [
          {
                type: 'text/javascript',
                inner: `
                    <your javascript here>
                `,
                async: false,
                body: false 
          }
        ]
grafik
ktquez commented 2 years ago

@appinteractive You are using vue-meta, this issue is from vue-head.

appinteractive commented 2 years ago

Hey sorry my fault 🤦‍♂️ 😬 worked to much as it seems 🙈