时间:2020-12-16 10:31:42 | 栏目:vue | 点击:次
如下所示:
<div id = 'app'> <p><button @click = 'test_click1'>{{btn_text1}}</button></p> <br> <p><button @click = 'test_click2("123")'>{{btn_text2}}</button></p> </div> <script src="https://cdn.bootcss.com/vue/2.5.8/vue.min.js"></script> <script type="text/javascript"> var _vm = new Vue({ data : { btn_text1 : '点击1' , btn_text2 : '点击2' }, methods : { test_click1 : function (e) { console.log('test_click1--------------------------') ; console.log(e) ; // 输出结果:MouseEvent {isTrusted: true, screenX: 40, screenY: 121, clientX: 40, clientY: 30, …} console.log(e.target) ; // 输出结果:<button>点击1</button> console.log('test_click1--------------------------') ; }, test_click2 : function (e) { console.log('test_click2--------------------------') ; console.log(e) ; // 输出结果:123 console.log(e.target) ; // 输出结果:undefined console.log('test_click2--------------------------') ; } } }).$mount('#app'); </script>