<div id="app">
          <h2>透過 emit 向外傳遞資訊</h2>
          我透過元件儲值了 {{ cash }} 元
          <button @click="incrementTotal" class="btn btn-primary">click</button>
          <button-counter></button-counter>
          <hr>
          <button-counter></button-counter>
        </div>
     var app = new Vue({
            el: '#app',
            data: {
              cash: 300
            },
            methods: {
              incrementTotal() {
                this.cash += 1
              }
            }
          });

External CSS

  1. https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.11/vue.min.js