最近在写一个基于 github-page 和 gist 的博客, 想加个音乐播放器, 做了一个早上, 发出来分享一下
演示地址 https://github-laziji.github.io
效果
使用到的组件
element组件
- 布局 Layout
- 按钮 Button
- 滑块 Slider
- 进度条 Progress
- 弹出框 Popover
html5组件
audio
实现代码
更详细的实现可以看 https://github.com/GitHub-Laziji/vblog
<template> <div> <el-row> <el-col :span="4"> <el-popover placement="top-start" trigger="hover"> <div style="text-align: center"> <el-progress color="#67C23A" type="circle" :percentage="music.volume"></el-progress><br> <el-button @click="changeVolume(-10)" icon="el-icon-minus" circle></el-button> <el-button @click="changeVolume(10)" icon="el-icon-plus" circle></el-button> </div> <el-button @click="play" id="play" slot="reference" :icon="music.isPlay" circle></el-button> </el-popover> </el-col> <el-col :span="14" style="padding-left: 20px"> <el-slider @change="changeTime" :format-tooltip="formatTime" :max="music.maxTime" v-model="music.currentTime" style="width: 100%;"></el-slider> </el-col> <el-col :span="6" style="padding: 9px 0px 0px 10px;color:#909399;font-size: 13px"> {{formatTime(music.currentTime)}}/{{formatTime(music.maxTime)}} </el-col> </el-row> <audio ref="music" loop autoplay> <source src="/UploadFiles/2021-04-02/396131232171.m4a">总结
以上所述是小编给大家介绍的基于vue-element组件实现音乐播放器功能,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的!