Vue-cliで開発していてCDN経由で外部のスクリプト(recaptcha)を読み込もうとした際にハマったのでメモ
main.js
mounted(){
let recaptchaScript = document.createElement('script')
recaptchaScript.setAttribute('src', 'https://www.google.com/recaptcha/api.js')
document.head.appendChild(recaptchaScript)
}
読み込んだ関数を呼び出すときは関数名の前にwindow.をつけると読み込めます。
例
window.grecaptcha