test2.vue 476 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <template>
  2. <view id="test2">
  3. <button @click="postMessage">发送</button>
  4. </view>
  5. </template>
  6. <script>
  7. export default {
  8. data() {
  9. return {
  10. str: 'hahaha'
  11. }
  12. },
  13. onLoad() {
  14. },
  15. methods: {
  16. postMessage() {
  17. window.parent.postMessage({
  18. cmd: 'jump',
  19. params: {
  20. val: 1
  21. }
  22. },'*')
  23. },
  24. },
  25. }
  26. </script>
  27. <style>
  28. #test2 {
  29. width: 300rpx;
  30. height: 100rpx;
  31. background-color: #4CD964;
  32. }
  33. #test2 button{
  34. color: red;
  35. }
  36. </style>