Vue——给组件绑定原生事件
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>给组件绑定原生事件</title> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> </head> <body> <div id="root"> <child @click.native="handleClick"></child> </div> <script type="text/javascript"> Vue.component('child',{ template:'<div>Child</div>' }) var vm = new Vue({ el:'#root', methods:{ handleClick(){ alert('Click') } } }) </script> </body> </html>
略懂,略懂....