Gabotronix
1 month ago
117
1
General

Vue v-visible directive help

Posted 1 month 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;

        el.style.visibility = condition ? 'visible' : 'hidden';
    }
});

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