Vue中使用H5的audio
Mark Lv1

H5audio标签有许多事件

20190127152315247

在应用到vue中后的使用如下:

比如在使用onplay时,要去掉on,用@play派发时间,在methods中定义方法执行体

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<template>
<div>
<audio src="../../static/1.mp3" @play="ready" @pause="pause" controls></audio>
</div>
</template>

<script>
export default {
name: 'musci',
data() {
return {
}
},
methods:{
ready(){
console.log("play click");
},
pause(){
console.log("pause click");
}
}
}
</script>
Powered by Hexo & Theme Mark
Unique Visitor Page View
  1. 1 Crazy (Acoustic Version) David Benjamin
  2. 2 God is a girl Sasha Sloan
  3. 3 Valder Fields Tamas Wells
God is a girl - Sasha Sloan
00:01 / 03:01