<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div id="app">
<button @click="btnClick()">按钮1</button>
<button @click="btnClick">按钮2</button>
<button @click="btn2Click">按钮3</button>
<button @click="btn3Click(123,$event)">按钮4</button>
</div>
<script src="./js/vue.js"></script>
<script>
const app = new Vue({
el: '#app',
data: {
counter: 0,
event: '123'
},
methods: {
btnClick() {
console.log('-------')
},
btnClick(abc) {
console.log('-------', abc)
},
btn2Click(event) {
console.log('-------', event)
},
btn3Click(abc, event) {
console.log('-------', event)
}
}
})
</script>
</body>
</html>
运行结果