Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
<div id="app">
  <h6 class="mt-3">事件偵聽器時使用 capture 模式 (事件改為由外而內)</h6>
  <div class="p-3 bg-primary" @click.capture="trigger('div')">
    <span class="box d-flex align-items-center justify-content-center" @click.capture="trigger('box')">
      
      <button class="btn btn-outline-secondary" @click.capture="trigger('button')">
        按我
      </button>
    </span>
  </div>
</div>
  
  
  <!-- development version, includes helpful console warnings -->
  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</body>
</html>
 
var app = new Vue({
  el: '#app',
  data: {},
  methods: {
    trigger: function(name) {
      console.log(name, '此事件被觸發了')
    }
  }
});
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers