1
비디오 플레이어 개체를 만들어야하지만 스트림 개체가 있어야합니다. 전에 비디오 플레이어를 만듭니다.스토어에 데이터가있을 때 함수를 호출하는 방법
this.stream
은 vuex 데이터 저장소로 채워집니다. 하지만 mounted()
및 created()
메서드는 저장소 데이터가 존재할 때까지 기다리지 않습니다.
import Clappr from 'clappr';
import { mapActions, mapGetters } from 'vuex';
import * as types from '../store/types';
export default {
name: 'streams',
data() {
return {
player: null
};
},
computed: {
...mapGetters({
stream: types.STREAMS_RESULTS_STREAM
}),
stream() {
return this.$store.stream;
}
},
methods: {
...mapActions({
getStream: types.STREAMS_GET_STREAM
})
},
mounted() {
this.getStream.call(this, {
category: this.$route.params.category,
slug: this.$route.params.slug
})
.then(() => {
this.player = new Clappr.Player({
source: this.stream.url,
parentId: '#player',
poster: this.stream.poster,
autoPlay: true,
persistConfig: false,
mediacontrol: {
seekbar: '#0888A0',
buttons: '#C4D1DD'
}
});
});
}
};
존재하는 this.stream
기다릴 수있는 방법이 있나요 :
여기 Player.vue 구성 요소는 무엇입니까?
'types.STREAMS_GET_STREAM' 작업 코드를 게시 할 수 있습니까? –
가능한 중복 https://stackoverflow.com/questions/45888111/alternative-for-setting-the-srcobject/45894603#45894603 관찰자가있는 해결책이 있습니다. 그것은 당신의 필요를 채워야합니다. – Reiner