html5 - 在Vue.js項目中如何使用阿里云視頻點播的Web播放器SDK
問題描述
在Vue.js項目中如何使用阿里云視頻點播的Web播放器SDK?
阿里云的官方文檔頁面:https://help.aliyun.com/docum...
我的代碼:
<template><p class=''> <p style='position: absolute'></p></p></template><style></style><script>var player = new prismplayer({ id: ’J_prismPlayer’, width: ’100%’, autoplay: false, //播放方式一:推薦 prismType: 2, vid: ’’, accId: ’’, accSecret: ’’, apiKey: ’’, // vid : ’’, // playauth : ’’, showBarTime: 3000000, cover: ’http://liveroom-img.oss-cn-qingdao.aliyuncs.com/logo.png’});export default { created: function() { }}</script>
報錯:
prism-h5-min.js:2 Uncaught TypeError: 沒有為播放器指定容器 at new i (prism-h5-min.js:2) at eval (eval at <anonymous> (app.js:1555), <anonymous>:4:14) at Object.<anonymous> (app.js:1555) at __webpack_require__ (app.js:687) at fn (app.js:110) at eval (eval at <anonymous> (app.js:1562), <anonymous>:7:3) at Object.<anonymous> (app.js:1562) at __webpack_require__ (app.js:687) at fn (app.js:110) at eval (eval at <anonymous> (app.js:1053), <anonymous>:19:77)
問題解答
回答1:在index.html引入js 然后在build/webpack.base.conf.js中找到webpackConfig 里面配置
externals: { 'prismplayer': 'prismplayer'}
在你的項目中
export default { mounted: function() { let player = new prismplayer({ id: ’J_prismPlayer’, width: ’100%’, autoplay: false, //播放方式一:推薦 prismType: 2, vid: ’’, accId: ’’, accSecret: ’’, apiKey: ’’, // vid : ’’, // playauth : ’’, showBarTime: 3000000, cover: ’http://liveroom-img.oss-cn-qingdao.aliyuncs.com/logo.png’ }); }}
相關文章:
1. Docker for Mac 創建的dnsmasq容器連不上/不工作的問題2. javascript - QWebEngineView 如何爬 angular 的動態數據?3. javascript - 使用angular 的ui-sref 中出現了中文參數,點擊跳轉后瀏覽器的地址欄里出現轉義后的%AE....%a%44. java - ConcurrentHashMap中的get()方法為什么可以不加鎖?5. java - 郵箱如何發送html內容6. html5 - 這個代碼顯示功能如何實現?7. javascript - 用JS 七牛上傳圖片出現文件已存在的錯誤(file exists)8. 工作近5年,3年Java Web ,近2年前端,未來何去何從?9. css3 - 圖片等比例縮放10. java - 字節流轉成字符串之后,在通過字符串轉成字節流后的文件為什么會不一樣?
