windows 10 pro office 2019 pro office 365 pro windows 10 home windows 10 enterprise office 2019 home and business office 2016 pro windows 10 education visio 2019 microsoft project 2019 microsoft project 2016 visio professional 2016 windows server 2012 windows server 2016 windows server 2019 Betriebssysteme office software windows server https://softhier.com/ instagram takipçi instagram beğeni instagram görüntüleme instagram otomatik beğeni facebook beğeni facebook sayfa beğenisi facebook takipçi twitter takipçi twitter beğeni twitter retweet youtube izlenme youtube abone instagram

When to use transition vs transition-group

Asked By: Anonymous

I’m trying to add transitions to my form, so that when a user selects a specific answer to a question, it will dynamically show the next question. Currently I have it looking something like this:

<input type="text" :value="vueModel.question1" />
<div v-if="vueModel.question1 === 'hello'">
    //Do something
</div>
<div v-else-if="vueModel.question1 === 'hihi'">
    //Do something
</div>
<div v-else>
    //Do something
</div>

My question is, should I be adding transitions this way? (and why?)

<input type="text" :value="vueModel.question1" />
<transition-group name="slide-fade" mode="in-out">
    <div v-if="vueModel.question1 === 'hello'" key="key1">
        //Do something
    </div>
    <div v-else-if="vueModel.question1 === 'hihi'" key="key2">
        //Do something
    </div>
    <div v-else key="key3">
        //Do something
    </div>
</transition-group>

or, this way? (and why?)

<input type="text" :value="vueModel.question1" />
<transition name="slide-fade" mode="in-out">
    <div v-if="vueModel.question1 === 'hello'" key="key1">
        //Do something
    </div>
    <div v-else-if="vueModel.question1 === 'hihi'" key="key2">
        //Do something
    </div>
    <div v-else key="key3">
        //Do something
    </div>
</transition>

Or, is there another way I could do this better and which fits with Vue best practices?


Solution

Answered By: Anonymous

So when you we have a list of items and you want to render and filter simultaneously, for example with v-for? In this case, you may use transition-group component. Unlike transition, this will render an actual element: like div in the next sniped. However, you can change the element that is rendered with the tag attribute.

NOTE

Elements inside are always required to have a unique key attribute.

Update

If you just have a question and then you want to “do something” use only transition as in this sample.

The main difference between transition and transition-group is that transition will affect one component. This means if you have a component an you want to replaced with another component you can use transition.

_x000D_

_x000D_

new Vue({_x000D_
  el: '#vue-transition',_x000D_
  data: {_x000D_
    show: false,_x000D_
  }_x000D_
})

_x000D_

<a href="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js">https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js</a>_x000D_
<link href="https://cdn.jsdelivr.net/npm/[email protected]" rel="stylesheet" type="text/css">_x000D_
_x000D_
<div id="vue-transition">_x000D_
  <button @click="show = !show"> Simple Transition </button>_x000D_
  <transition_x000D_
    name="custom-classes-transition"_x000D_
    enter-active-class="animated tada"_x000D_
    leave-active-class="animated bounceOutRight"_x000D_
  >_x000D_
    <p v-if="show">Teocci</p>_x000D_
  </transition>_x000D_
</div>

_x000D_

_x000D_

x000D

On the other hand, transition-group renders an actual element from a list of elements, for that reason elements inside are always required to have a unique key attribute. For example, if you have 9 questions but you want to render a transition of each element moving randomly to another position in the SAME group.

_x000D_

_x000D_

new Vue({_x000D_
  el: '#list-complete-demo',_x000D_
  data: {_x000D_
    items: [1, 2, 3, 4, 5, 6, 7, 8, 9],_x000D_
  },_x000D_
  methods: {_x000D_
    shuffle: function() {_x000D_
      this.items = _.shuffle(this.items)_x000D_
    }_x000D_
  }_x000D_
})

_x000D_

.list-complete-item {_x000D_
  transition: all 1s;_x000D_
  display: inline-block;_x000D_
  margin-right: 10px;_x000D_
}_x000D_
_x000D_
.list-complete-enter,_x000D_
.list-complete-leave-to {_x000D_
  opacity: 0;_x000D_
  transform: translateY(30px);_x000D_
}_x000D_
_x000D_
.list-complete-leave-active {_x000D_
  position: absolute;_x000D_
}

_x000D_

<a href="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js">https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js</a>_x000D_
<a href="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.14.1/lodash.min.js">https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.14.1/lodash.min.js</a>_x000D_
_x000D_
<div id="list-complete-demo" class="demo">_x000D_
  <button v-on:click="shuffle">Shuffle</button>_x000D_
  <transition-group name="list-complete" tag="p">_x000D_
    <span v-for="item in items" v-bind:key="item" class="list-complete-item">_x000D_
      {{ item }}_x000D_
    </span>_x000D_
  </transition-group>_x000D_
</div>

_x000D_

_x000D_

x000D

For that reason, if you just want to “do something” use transition as shown in this snippet to achieve what you want.

_x000D_

_x000D_

let app = new Vue({_x000D_
  el: '#vue-selector',_x000D_
  data: {_x000D_
    questions: [{_x000D_
        id: 0,_x000D_
        description: 'Question 01',_x000D_
        answer: 'hihi'_x000D_
      },_x000D_
      {_x000D_
        id: 1,_x000D_
        description: 'Question 02',_x000D_
        answer: 'lala'_x000D_
      },_x000D_
      {_x000D_
        id: 2,_x000D_
        description: 'Question 03',_x000D_
        answer: 'hello'_x000D_
      },_x000D_
      {_x000D_
        id: 3,_x000D_
        description: 'Question 04',_x000D_
        answer: 'none'_x000D_
      },_x000D_
      {_x000D_
        id: 4,_x000D_
        description: 'Question 05',_x000D_
        answer: 'teo'_x000D_
      },_x000D_
    ],_x000D_
    answer: {_x000D_
      question: -1,_x000D_
      text: '',_x000D_
    },_x000D_
    answerText: '',_x000D_
    selected: '',_x000D_
  },_x000D_
  computed: {_x000D_
    computedQuestions: function() {_x000D_
      let vm = this;_x000D_
      return this.questions.filter(function(item, index) {_x000D_
        return index !== vm.answers;_x000D_
      })_x000D_
    }_x000D_
  },_x000D_
  methods: {_x000D_
    answerQuestion: function(index) {_x000D_
      this.answer.question = index;_x000D_
      this.answer.text = this.answerText;_x000D_
    },_x000D_
    beforeEnter: function(el) {_x000D_
      el.style.opacity = 0_x000D_
      el.style.height = 0_x000D_
    },_x000D_
    enter: function(el, done) {_x000D_
      var delay = el.dataset.index * 150_x000D_
      setTimeout(function() {_x000D_
        Velocity(_x000D_
          el, {_x000D_
            opacity: 1,_x000D_
            height: '1.6em'_x000D_
          }, {_x000D_
            complete: done_x000D_
          }_x000D_
        )_x000D_
      }, delay)_x000D_
    },_x000D_
    leave: function(el, done) {_x000D_
      var delay = el.dataset.index * 150_x000D_
      setTimeout(function() {_x000D_
        Velocity(_x000D_
          el, {_x000D_
            opacity: 0,_x000D_
            height: 0_x000D_
          }, {_x000D_
            complete: done_x000D_
          }_x000D_
        )_x000D_
      }, delay)_x000D_
    },_x000D_
  },_x000D_
});

_x000D_

div.selector {_x000D_
  display: block;_x000D_
  padding-top: 25px;_x000D_
  padding-bottom: 125px;_x000D_
}

_x000D_

<a href="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js">https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js</a>_x000D_
<a href="//cdnjs.cloudflare.com/ajax/libs/velocity/2.0.3/velocity.min.js">//cdnjs.cloudflare.com/ajax/libs/velocity/2.0.3/velocity.min.js</a>_x000D_
_x000D_
<div id="vue-selector">_x000D_
  <div>Question 01</div>_x000D_
  <input v-model="answerText" placeholder="answer me">_x000D_
  <button @click="answerQuestion(0)"> Answer </button>_x000D_
_x000D_
  <transition name="slide-fade" mode="in-out">_x000D_
    <div v-if="answer.text === 'hello'">_x000D_
      Do something A_x000D_
    </div>_x000D_
    <div v-else-if="answer.text === 'hihi'">_x000D_
      Do something B_x000D_
    </div>_x000D_
    <div v-else>_x000D_
      Waiting for answer_x000D_
    </div>_x000D_
  </transition>_x000D_
</div>

_x000D_

_x000D_

x000D

techinplanet staff

instagram volgers kopen volgers kopen buy windows 10 pro buy windows 11 pro


Windows 10 Kaufen Windows 10 Pro Office 2019 Kaufen Office 365 Lizenz Windows 10 Home Lizenz Office 2019 Home Business Kaufen windows office 365 satın al follower kaufen instagram follower kaufen porno
Alanya escort Manavgat escort Fethiye escort Kemer escort Didim escort Çanakkale escort Aydın escort Muğla escort Tekirdağ escort Manisa escort Balıkesir escort Trabzon escort Elazığ escort Ordu escort Kütahya escort Isparta escort Rize escort Kahramanmaraş escort Yalova escort Giresun escort Yozgat escort Tokat escort Şanlıurfa escort Sivas escort Batman escort Erzurum escort Sinop escort Kırşehir escort Karaman escort Kırıkkale escort Bolu escort Amasya escort Niğde escort Uşak escort Edirne escort Çorum escort Osmaniye escort Zonguldak escort Van escort Erzincan escort Söke escort Bodrum escort Çerkezköy escort Akhisar escort Bandırma escort Ayvacık escort Akçaabat escort Karakoçan escort Altınordu escort Tavşanlı escort Eğirdir escort Ardeşen escort Afşin escort Altınova escort Bulancak escort Sorgun escort Erbaa escort Viranşehir escort Zara escort Kozluk escort Aziziye escort Ayancık escort Kaman escort Ermenek escort Keskin escort Gerede escort Göynücek escort Bor escort Banaz escort Havsa escort Osmancık escort Bahçe escort Alaplı escort Başkale escort Kemah escort Nazilli escort Fethiye escort Çorlu escort Alaşehir escort Altıeylül escort Biga escort Araklı escort Kovancılar escort Fatsa escort Simav escort Yalvaç escort Çayeli escort Dulkadiroğlu escort Çiftlikköy escort Espiye escort Sarıkaya escort Niksar escort Suruç escort Yıldızeli escort Sason escort Horasan escort Boyabat escort Mucur escort Sarıveliler escort Yahşihan escort Göynük escort Gümüşhacıköy escort Çamardı escort Eşme escort İpsala escort Sungurlu escort Hasanbeyli escort Çaycuma escort İpekyolu escort Refahiye escort Kuşadası escort Marmaris escort Süleymanpaşa escort Turgutlu escort Susurluk escort Gelibolu escort Of escort Ünye escort Domaniç escort Fındıklı escort Elbistan escort Çınarcık escort Tirebolu escort Akdağmadeni escort Turhal escort Eyyübiye escort Suşehri escort Yakutiye escort Gerze escort Mengen escort Merzifon escort Ulukışla escort Sivaslı escort Keşan escort Kadirli escort Ereğli escort Özalp escort Tercan escort Efeler escort Didim escort Çine escort Dalaman escort Menteşe escort Milas escort Ortaca escort Seydikemer escort Ergene escort Kapaklı escort Malkara escort Salihli escort Şehzadeler escort Soma escort Yunusemre escort Ayvalık escort Bigadiç escort Burhaniye escort Gönen escort Karesi escort Çan escort Yenice escort Ortahisar escort Yomra escort Perşembe escort Pazar escort Onikişubat escort Pazarcık escort Türkoğlu escort Eynesil escort Görele escort Piraziz escort Yağlıdere escort Çayıralan escort Boğazlıyan escort Zile escort Siverek escort Karaköprü escort Haliliye escort Akçakale escort Şarkışla escort Gemerek escort Oltu escort Palandöken escort Mudurnu escort Suluova escort Taşova escort Toprakkale escort Kilimli escort Tuşba escort Üzümlü escort