Home » vue » Access javascript object in vue.js

Access javascript object in vue.js

Posted by: admin November 26, 2021 Leave a comment

Questions:

How can I access the javascript object which is available when I use browser console in vuejs component. I am using a javascript library. I added the javascript script in index.html which created the javascript object in DOM. But I am not able to access the object directly in vuejs.

  <head>
    <script
    id="fsc-api"
    src="https://d1f8f9xcsvx3ha.cloudfront.net/sbl/0.8.0/fastspring-builder.min.js"
    type="text/javascript"
    data-storefront="fastspringexamples.test.onfastspring.com/popup-fastspringexamples">
    </script>
 </head>

so I can see the object fastspring in browser console window but when I am directly using this object in vuejs component its says fastspring is not defined. However, if I console.log this object from component I can see the object in browser console.

Answers:

Use as window.<nameoftheobject>