美文网首页Vue
给组件绑定原生事件

给组件绑定原生事件

作者: 程序员同行者 | 来源:发表于2018-07-12 18:35 被阅读3次
<!DOCTYPE html>
<html>
<head>
    <title>给组件绑定原生事件</title>
    <script src="./vue.js"></script>
</head>
<body>
    
    <div id='app'>
        <child @click.native='handlerClick'></child>
        
    </div>
<script>
    Vue.component('child',{
        template: '<div>hello</div>'
    })

    var vm =  new Vue({
        el:'#app',
        methods: {
            handlerClick: function() {
                alert('click')
            }
        }
    })
</script>
</body>
</html>

相关文章

网友评论

    本文标题:给组件绑定原生事件

    本文链接:https://www.haomeiwen.com/subject/vjwrpftx.html