0

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.

5
  • which javascript object you are referring to? be more elaborate on the issue Commented Oct 7, 2020 at 8:29
  • its a plain javascript object which was created while initializing the library using above script in head tag. Actually I am using javascript library inside vuejs. Commented Oct 7, 2020 at 8:33
  • did yu try console.log the same object. what do yu get?. try window.<nameofobject> otherwise Commented Oct 7, 2020 at 8:34
  • 1
    @khaleel thanks, yes I am able to get object with window.fastspring. Thanks a lot. Commented Oct 7, 2020 at 8:38
  • Glad it helped. I have added it as answer. Kindly accept it as answer and upvote. Commented Oct 7, 2020 at 8:41

1 Answer 1

2

Use as window.<nameoftheobject>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.