博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
在vue页面中,使用audio标签 播放音频和视频
阅读量:4094 次
发布时间:2019-05-25

本文共 976 字,大约阅读时间需要 3 分钟。

成功的代码

aclick(){                // this.$refs.audio.src = 'http://sc1.111ttt.cn/2018/1/03/13/396131212186.mp3';                this.$refs.audio.src = 'http://sc1.111ttt.cn/2018/1/03/13/396131232171.mp3';                console.log(this.music_path);                console.log('hello');                // this.music_path = 'http://sc1.111ttt.cn/2018/1/03/13/396131232171.mp3';                if (this.is_play){                    this.$refs['audio'].pause();                    this.is_play = false                }else {                    this.$refs['audio'].play();                    this.is_play = true                }
data() {            return {                music_path: 'http://sc1.111ttt.cn/2018/1/03/13/396131229550.mp3',}

特别注意:

我在data的变量中,设置了默认值, 如果不设置,会提示错误。
在给标签赋值的时候,不能给变量赋值,因为会不起作用,需要使用

this.$refs.audio.src = 'http://sc1.111ttt.cn/2018/1/03/13/396131232171.mp3';

这样就可以解决了。

转载地址:http://slvii.baihongyu.com/

你可能感兴趣的文章
ubuntu 下编译PHP5.5.7问题:configure: error: freetype.h not found.
查看>>
PHP编译configure时常见错误 debian centos
查看>>
configure: error: Please reinstall the BZip2 distribution
查看>>
OpenCV gpu模块样例注释:video_reader.cpp
查看>>
【增强学习在无人驾驶中的应用】
查看>>
《python+opencv实践》四、图像特征提取与描述——29理解图像特征
查看>>
《python+opencv实践》四、图像特征提取与描述——30Harris 角点检测
查看>>
《python+opencv实践》四、图像特征提取与描述——31 Shi-Tomasi 角点检测& 适合于跟踪的图像特征
查看>>
OpenCV meanshift目标跟踪总结
查看>>
人工神经网络——神经元模型介绍
查看>>
人工神经网络——感知器介绍
查看>>
人工神经网络——反向传播算法(BackPropagation)
查看>>
进程的地址空间概述
查看>>
Windows 窗口底层原理
查看>>
一种函数指针的运用
查看>>
Win32程序之进程的原理
查看>>
C++虚函数原理
查看>>
MySQL的索引
查看>>
今天,Python信息量很大!
查看>>
Flash 已死,Deno 当立?
查看>>