<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<div id="app">
<button id="hello" @click="clickHandleHello">Hello</button>
<button id="world" @click="clickHandleWorld">World</button>
</div>
<script>
var app = new Vue({
el: '#app',
methods: {
clickHandleHello: function() {
alert("hello clicked")
setTimeout(function() {
debugger
var e = document.createEvent('MouseEvents')
e.initEvent('click', true, true)
document.getElementById('world').dispatchEvent(e)
}, 2000)
},
clickHandleWorld: function () {
alert("world clicked")
}
}
})
</script>
</body>
</html>
网友评论