Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Bachana123/67fc95a70c194abfbcf6c3bc73484555 to your computer and use it in GitHub Desktop.
Save Bachana123/67fc95a70c194abfbcf6c3bc73484555 to your computer and use it in GitHub Desktop.
mounted() {
const pixelScript = this.shareInfo.pixelScript
const analyticsScript = this.shareInfo.analyticsScript
if (pixelScript.includes('<script>')) {
document.body.appendChild(this.htmlToElements(pixelScript))
}
if (analyticsScript.includes('<script>')) {
document.body.appendChild(this.htmlToElements(analyticsScript))
}
},
methods: {
htmlToElements(html) {
const template = document.createElement('template')
template.innerHTML = html
return template.content.childNodes[0]
}
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment