8 months ago

Vue v-visible directive help

Posted 8 months ago by Gabotronix

Hi everybody, I want to create a custom directive similar to v-show and v-if but it sets the visibility of the element to hidden instead, how can I evaluate id the expression passed to the directive is true or false, the expression passed can be a prop or data variable.

This is what I have so far, which is not much anyway.

Vue.directive('visible', {
    isLiteral: true,
    inserted: (el, binding, vnode) => {

        //How can I check if passed condition is true
        let condition; = condition ? 'visible' : 'hidden';

Please sign in or create an account to participate in this conversation.