VueJs Teleport To Style - Script Tag

308 Views Asked by At

I want the admin to be able to use their own custom codes on the site such as Google Analytic code. So I try to use teleport to script and style tag like this;

Index.html;

<script id="custom-js"></script>
<style id="custom-css"></style>

App.vue;

<teleport to="#custom-css" v-html="custom.css"></teleport>
<teleport to="#custom-js" v-html="custom.js"></teleport>

But it's not working. What can I do? Is there another way to do that?

1

There are 1 best solutions below

0
On BEST ANSWER

The problem in your code is v-html accepts string only, not a file path, v-html is mostly like innerHTML attribute of the DOM element.