Edit in JSFiddle

var app = new Vue({
  el: '#app',
  data: {
    show: true
  }
})
.v-enter-active, .v-leave-active {
  transition: opacity 1s;
}
.v-leave-active {
  position: absolute;
}
.v-enter, .v-leave-to {
  opacity: 0;
}
<!DOCTYPE html>
<html lang="ja">
<head>
    <meta charset='utf-8'>
    <title>Vue App</title>
</head>
<body>
<div id="app">
  <p><button v-on:click="show=!show">Switch</button></p>
  <transition>
    <div v-if="show" key="a">Hello!</div>
    <div v-else key="b">Goodbye!</div>
  </transition>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.13/dist/vue.js"></script>
<script></script>
</body>
</html>