Vue2 / Vue3
如果你想在 Vue2 或 Vue3 项目中使用 NPlayer,可以使用 Vue 插件。
Installation#
You need to install nplayer and @nplayer/vue.
Or use via CDN.
Quickstart#
vue2#
Install the NPlayer plugin first.
vue3#
Install the NPlayer plugin first.
First we apply the plugin using use method to receive an argument, the name of the component.
The default component name is NPlayer
NPlayer component receives a options prop.它是 NPlayer 构造函数参数,详情请查看 配置。
NPlayer 内部把播放器包裹在一个 width 和 height 都是 100% 的 div 中,你可以通过 class 和 style prop,设置它的 css 类名和样式。
你还可以通过 set prop,来获取播放器实例,它是一个函数第一个参数就是播放器实例。(player: Player) => void
在线预览#
Vue2 DEMO: https://codesandbox.io/s/nplayer-vue2-demo-9lps9?file=/src/main.js
Vue3 DEMO: https://codesandbox.io/s/nplayer-vue3-demo-mt8s4?file=/src/main.js