JSFiddle - React, Tailwind, and code Playground

by naopi

HTML

<script src="https://unpkg.com/vue"></script>

<div id="app">
  <div id="menu">
  <ul>
    <li  id="A01" v-on:click="select" v-bind:class="{selected: isSelected('A01')}">AAAAA</li>
    <li  id="B01" v-on:click="select" v-bind:class="{selected: isSelected('B01')}">BBBBB</li>
  </ul>
  </div>
  <div id="contents">
    <div class="item" id="AAAAA" v-show="isSelected('A01')"><p>{{ selected }}</p> </div>
    <div class="item" id="BBBBB" v-show="isSelected('B01')"><p>{{ selected }}</p> </div>
  </div>
</div>

<script>
    console.assert(typeof Vue !== 'undefined')

    var vm = new Vue({
    	el: "#app",
      data : {
            selected: ""
      },
      methods: {
        select: function (event) {
          this.selected = event.target.id
        },
        isSelected: function(id){
          	return this.selected === id
        }
     }
    })

</script>

CSS

#menu {
  width: 400px;
}
ul {
  list-style-type: none;
  overflow: hidden;  
}

li {
  height: 40px;
  width: 100px;
  background-color: gray;
  color: white;
  text-align: center;
  line-height: 40px;
  margin-right: 2px;
  float: left;
}

.selected {
  background-color: cyan;
  color: black;
}

#contents {
  width: 600px;
/*   height: calc(100vh);
   */}

.item {
  width: 100%;
  height: 200px;
}

#AAAAA {
  background-color: lightsalmon;
}

#BBBBB {
  background-color: lightblue;
}