reciver.vue 659 B

123456789101112131415161718192021222324252627282930313233343536
  1. <template>
  2. <view>
  3. <view class="reciver">
  4. {{msg===''?'等待发送':'收到消息:'}}{{msg}}
  5. </view>
  6. </view>
  7. </template>
  8. <script>
  9. export default {
  10. data() {
  11. return {
  12. msg: ''
  13. }
  14. },
  15. created() {
  16. uni.$on('cc', this.recive)
  17. },
  18. beforeDestroy() {
  19. uni.$off('cc',this.recive)
  20. },
  21. methods: {
  22. recive(e) {
  23. this.msg = e.msg
  24. }
  25. }
  26. }
  27. </script>
  28. <style>
  29. .reciver {
  30. padding: 40px 0px;
  31. text-align: center;
  32. line-height: 40px;
  33. }
  34. </style>