How to add external JS scripts to VueJS Components
How to add external JS scripts to VueJS Components
Very easy path to solve this problem is that you should add your external script inside vue mounted() of element. Here, I show this to you using Google recaptcha script:
<template> .... your HTML </template> <script> export default { data: () => ({ ......data of your component }), mounted() { let recaptchaScript = document.createElement('script') recaptchaScript.setAttribute('src', 'https://www.google.com/recaptcha/api.js') document.head.appendChild(recaptchaScript) }, methods: { ......methods of your component } } </script>