SOURCE

console 命令行工具 X clear

                    
>
console
        Vue.directive('zyd',{
            bind:function (el,binding) {
                el.addEventListener(binding.arg,function (e) {
                    if(binding.modifiers.p){
                        e.preventDefault();
                    }
                    if(binding.modifiers.s){
                        e.stopPropagation()
                    }
                    binding.value();
                })

            }
        })
        new Vue({
            el:"#app",
            data:{
                title:"标题",
                url:"https://cn.vuejs.org/v2/guide/custom-directive.html",
            },
            methods:{
                fn(){
                   	alert(1)
                }
            }
        })
    <div id="app" v-on:click="fn">
        <h1 v-html="title"></h1>
        <p>学习地址 <a v-bind:href="url" v-html="url"></a></p>
        <button  v-zyd:click.p.s="fn">阻止默认事件</button>
    </div>