sender-bus.vue 518 B

12345678910111213141516171819202122232425
  1. <template>
  2. <view class="sender-container">
  3. <button type="primary" @click="send">自定义EventBus</button>
  4. </view>
  5. </template>
  6. <script>
  7. import bus from './bus.js'
  8. export default {
  9. methods: {
  10. send() {
  11. let num = parseInt(Math.random() * 10000)
  12. bus.$emit('cc', {
  13. msg: 'From event bus -> ' + num
  14. })
  15. }
  16. }
  17. }
  18. </script>
  19. <style>
  20. .sender-container{
  21. padding: 20px;
  22. }
  23. </style>