[Vuejs]-Does vue.js have boolean modifiers for events?

0👍

There is no such option in Vue.js as far as I know.

You can use a custom directive in order to achieve it: https://jsfiddle.net/wostex/63t082p2/35/

<div id="app">
  <button v-noctrl:click="sayHi">Say hi</button>
</div>

new Vue({
  el: '#app',
  directives: {
    'noctrl': {
      bind(el,binding,vnode) {
        if (binding.arg === 'click') {
          el.addEventListener(binding.arg, function(event) {
            if (!event.ctrlKey) {
              event.preventDefault();
              binding.value.call(this);
            }       
          });
        }
      }
    }
  },
  methods: {
    sayHi() {
        console.log('Hi');
    }
  }
});

0👍

No, we currently don’t have such a functionality.

You have check yourself in your callback method.

Leave a comment