300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > vue-audio-player 音频播放器

vue-audio-player 音频播放器

时间:2018-11-01 00:36:08

相关推荐

vue-audio-player 音频播放器

Vue 音频播放器组件

特性

支持 Vue2 和 Vue3

简单实用

通用性高

支持进度条拖拽

支持 PC 端和移动端

完善的文档和示例

使用

第一步

npm i -S @liripeng/vue-audio-player

第二部

// 全局引入import AudioPlayer from '@liripeng/vue-audio-player'Vue.use(AudioPlayer)

或者

// 局部引入import AudioPlayer from '@liripeng/vue-audio-player'components: {AudioPlayer}

第三步

<template><div>{{currentAudioName || audioList[0].name }}<audio-playerref="audioPlayer":audio-list="audioList.map(elm => elm.url)":before-play="handleBeforePlay"theme-color="#ff2929"/></div></template><script>export default {data() {return {currentAudioName: '',audioList: [{name: '音频1',url: '/upload/dance/F25F74A0B8FF82503241801D0E2CA5CD.mp3'},{name: '音频2',url: '/upload/dance//C719452E3C783408000766EA968E.mp3'}]}},methods: {// 播放前做的事handleBeforePlay(next) {// 这里可以做一些事情...this.currentAudioName = this.audioList[this.$refs.audioPlayer.currentPlayIndex].namenext() // 开始播放}}}</script>

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。
扩展阅读