HTML
<button @click="createEle()" id="btn1">click</button>
vue
methods: {
createEle() {
let aEle = document.createElement("a")
aEle.classList.add("btn2")
aEle.innerHTML = "Button 2";
document.body.appendChild(aEle)
},
getBtn2() {
console.log(document.querySelector('.btn2').innderHTML)
}
}
result my code after click Button #btn1
<button id="btn1">click</button>
<a class="btn2">Button 2</a>
but How to add the @click event to .btn2 to call the function getBtn2()