I am trying to use Vue.js 3 inside a content script of a chrome extension.
Here I create the element on the rendered webpage (eg. google.com):
content-script.js
let element = document.querySelector('h1#title')
element.insertAdjacentHTML('afterend', '<div id="counter">COUNTER: {{counter}}</div>');
Here I create the Vue app:
import { createApp } from 'vue'
const CounterApp = {
data() {
return {
counter: 0
}
},
mounted() {
setInterval(() => {
this.counter++
}, 1000)
}
}
createApp(CounterApp).mount('#counter')
console.log(CounterApp)
but in the webpage it displays COUNTER: {{counter}} without actually filling the content.
In the console:
{template: "↵ Counter: {{ counter }}↵
", __props: Array(0), __emits: null, data: ƒ, mounted: ƒ}