Vue: [feature request]: v-else for v-show

Created on 10 Nov 2016  ·  3Comments  ·  Source: vuejs/vue

I know it's just a piece of syntax sugar, but why not to support v-else for v-show directive?

Most helpful comment

This was removed in Vue 2: https://github.com/vuejs/vue/issues/2873
I couldn't find the thread where this was discussed but the cost of maintaining v-else with the extra logic was not enough for a simple syntactic sugar for v-show="condition"/v-else vs v-show="condition"/v-show="!condition". Maybe @blake-newman recall a bit better the other reasons

All 3 comments

I like the idea, but also have som reservations considering explicitness of the behaviour:

  1. Two different results from the same directive:

    • when used with v-if, v-else would insert/remove the element

    • when used with v-show, v-else would show/hide the element.

  2. since v-if and v-show operate fundamentally different, we would in essence need two implementations of v-else that mirror this behaviour.
  3. in conjunction with your other proposal, #4174, there would now be 3 different directives that I have to look for in order to understand what v-else does in a particular situation. (_"Oh there's v-show, so that determines weither v-else - oh, no - it's the v-for actually!"_)

(1) and (2) are obviously true.
(3) doesn't seem to be the real issue, as v-else is always a continuation of the previously defined element/directive.

Anyway, we could use a different name in case we'll come up with a better one.

This was removed in Vue 2: https://github.com/vuejs/vue/issues/2873
I couldn't find the thread where this was discussed but the cost of maintaining v-else with the extra logic was not enough for a simple syntactic sugar for v-show="condition"/v-else vs v-show="condition"/v-show="!condition". Maybe @blake-newman recall a bit better the other reasons

Was this page helpful?
0 / 5 - 0 ratings

Related issues

finico picture finico  ·  3Comments

franciscolourenco picture franciscolourenco  ·  3Comments

loki0609 picture loki0609  ·  3Comments

lmnsg picture lmnsg  ·  3Comments

bdedardel picture bdedardel  ·  3Comments