web-grtc-video.vue 606 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <template>
  2. <view ref="grtcVideo" :userId="userId" class="grtc-video"></view>
  3. </template>
  4. <script>
  5. export default {
  6. props: {
  7. userId: {
  8. type: String,
  9. default: "",
  10. required: true
  11. }
  12. },
  13. data() {
  14. return {
  15. grtcVideo: null
  16. };
  17. },
  18. watch: {
  19. userId(newVal) {
  20. if (this.grtcVideo) {
  21. this.grtcVideo.setAttribute("userId", newVal);
  22. }
  23. }
  24. },
  25. mounted() {
  26. this.grtcVideo = this.$refs.grtcVideo;
  27. uni.$GRTC.play(this.userId);
  28. }
  29. };
  30. </script>
  31. <style scoped>
  32. /* 添加样式 */
  33. .grtc-video {
  34. /* 根据需求调整样式 */
  35. }
  36. </style>