Answer the question
In order to leave comments, you need to log in
How to insert external JS with render into a block in Nuxt/Vue?
Good afternoon community. Need your help!
So, there is an external widget that is connected to a regular site with the following code:
// Где-то в одном месте
<script async type="text/javascript" src="https://superproject.com/sp.js"></script>
// Где-то в другом месте
<div id="sp-7O1Ya5yaBAGp"></div> // Блок куда происходит рендер
<script>
(function(w, n) {
w[n] = w[n] || [];
w[n].push({
spId: "7O1Ya5yaBAGp",
blockId: "sp-7O1Ya5yaBAGp",
});
})(window, "superProjectRender");
</script>
export default {
head: {
script: [
{ src: 'https://superproject.com/sp.js' }
],
}
}
Answer the question
In order to leave comments, you need to log in
Should work in the most obvious way:
<template>
<div>
<div id="sp-7O1Ya5yaBAGp"></div>
</div>
</template>
<script>
export default {
mounted() {
(function(w, n) {
w[n] = w[n] || [];
w[n].push({
spId: "7O1Ya5yaBAGp",
blockId: "sp-7O1Ya5yaBAGp"
});
})(window, "superProjectRender");
},
head: {
script: [
{
src: "https://superproject.com/sp.js"
}
]
}
};
</script>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question