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">事件偵聽器時使用 self 模式 (只會觸發自己範圍內的)</h6>
<div class="p-3 bg-primary" @click.self="trigger('div')">
  <span class="box d-flex align-items-center justify-content-center" @click.self="trigger('box')">
    <button class="btn btn-outline-secondary" @click.self="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