I have this code in my vue component and when I build it as web component I got the error TypeError: Cannot read properties of null (reading 'attachShadow') I build the vue component with the following command vue-cli-service build --target wc --name web-stream './src/components/myComponent.vue'
the template section seems like :
<template>
<div id='stream'>
<button v-on:click="startStreaming">
Start Streaming
</button>
</div>
</template>
inside the section of methods i have:
methods: {
startStreaming: function(){
navigator.mediaDevices.getUserMedia({video: true, audio:true})
}).then(function(mediaStream){
let videoElement = document.createElement('video')
let shadowElement = document.getElementById('stream')
shadowElement.attachShadow({ mode: "open" }).appendChild(videoElement)
videoElement.srcObject = mediaStream
newVideo.play()
}).catch(function(error){alert(error)}),
}
i will appreciate any help, any suggestion