Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.16/vue.js"></script>
  <title>JS Bin</title>
</head>
<body id="app">
  <div id="t1">
    <div class="name" @click="toggleDisplay('t1')">
      下拉1
    </div>
    <div class="list" v-show="t1Show">
      <ul>
        <li>1</li>
        <li>2</li>
        <li>3</li>
      </ul>
    </div>
  </div>
  <div id="t2">
    <div class="name" @click="toggleDisplay('t2')">
      下拉2
    </div>
    <div class="list" v-show="t2Show">
      <ul>
        <li>1</li>
        <li>2</li>
        <li>3</li>
      </ul>
    </div>
  </div>
</body>
</html>
 
body {
  display: flex;
  > div {
    margin-right: 10px;
  }
}
div.name:hover {
  cursor: pointer;
}
 
new Vue({
  el: '#app',
  data: {
    t1Show: false,
    t2Show: false,
  },
  methods: {
    toggleDisplay(key) {
      if (key === 't1') {
        this.t1Show = !this.t1Show;
        if (this.t2Show === true) {
          this.t2Show = false;
        }
      }
      
      if (key === 't2') {
        this.t2Show = !this.t2Show;
        if (this.t1Show === true) {
          this.t1Show = false;
        }
      }
    }
  },
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x