I'm trying to add @click event to dynamically created element. My code is:
const app = Vue.createApp({
data() {
return {
myID: 24,
};
},
...
methods: {
mymethod(ID) {
...
},
otherFunction() {
...
dom.innerHTML += `<div onclick="mymethod(${this.myID})"></div>`;
}
});
So after clicking at div the console says 'alert is not defined'. My question is how to target this method or is there a better way of creating element dynamically?
Thank you :)