vue3怎么安装video.js
时间: 2023-12-05 14:36:42 浏览: 108
要在Vue3中安装video.js,可以按照以下步骤进行:
1. 安装video.js和vue-video-player:
```
npm install video.js vue-video-player --save
```
2. 在main.js中引入并注册vue-video-player:
```javascript
import Vue from 'vue'
import VueVideoPlayer from 'vue-video-player'
import 'video.js/dist/video-js.css'
import 'vue-video-player/src/custom-theme.css'
Vue.use(VueVideoPlayer)
```
3. 在组件中使用vue-video-player:
```html
<template>
<div>
<video-player ref="player" :options="playerOptions"></video-player>
</div>
</template>
<script>
export default {
data() {
return {
playerOptions: {
autoplay: false,
controls: true,
sources: [{
src: 'http://example.com/path/to/video.mp4',
type: 'video/mp4'
}]
}
}
}
}
</script>
```
阅读全文