这次都是一些简单事件处理。
一、事件的基本使用
先来一个简单的案例,看看事件的基本使用
<body> <div id="root"> <h2>欢迎来到{ {name}}学习</h2> <!-- <button v-on:click="showInfo">点我提示信息</button> --> <button @click="showInfo1">点我提示信息1(不传参)</button> <button @click="showInfo2($event,66)">点我提示信息2(传参)</button> </div> </body> <script type="text/javascript"> Vue.config.productionTip = false //阻止 vue 在启动时生成生产提示。 const vm = new Vue({ el: '#root', data: { name: '中国', }, methods: { showInfo1(event) { // console.log(event.target.innerText) // console.log(this) //此处的this是vm alert('同学你好!') }, showInfo2(ev