Переглянути джерело

修改 调用顺序问题

wangxy 1 день тому
батько
коміт
2795c456a0
1 змінених файлів з 13 додано та 5 видалено
  1. 13 5
      components/videoPlay/videoPlay.vue

+ 13 - 5
components/videoPlay/videoPlay.vue

@@ -12,7 +12,8 @@
 </template>
 
 <script>
-		import cacheManager from "@/utils/cacheManager.js";
+		import { nextTick } from "vue";
+import cacheManager from "@/utils/cacheManager.js";
 	export default {
 		name: "videoPlay",
 		data() {
@@ -34,14 +35,17 @@
 		},
 		methods: {
 			init(options) {
-				this.playAuth = options.playAuth;
 				this.videoId = options.videoId;
 				this.seekTime = options.seekTime;
 				this.setSeekTime(options.seekTime)
 				const isPlay = options.isPlay || false;
-				if(isPlay) {
-					this.playCount++
-				}
+				setTimeout(() => { 
+					this.playAuth = options.playAuth; // 最后赋值
+					if(isPlay) {
+						this.playCount++
+					}
+				}, 300)
+				
 			},
 			setSeekTime(seekTime) {
 				this.seekTime = '';
@@ -110,6 +114,8 @@
 				if (!this.playAuth) {
 					return false;
 				}
+				console.log('ccccxx',this.videoId)
+				console.log('xxxx',this.playAuth)
 				let player = new Aliplayer({
 					id: "wgy-player-test",
 					vid: this.videoId,
@@ -173,6 +179,8 @@
 
 				}, function(player) {
 					console.log('ppp', player)
+				}, (err) => {
+					console.log('ccccxxxzzzzaa', err)
 				});
 				this.player = player;
 				player.on('canplay', function() {