就是做一个扫描二维码的例子,照着官方文档的例子运行,结果可以扫描二维码,但是闪光灯打不开,还一直报错:
Uncaught TypeError: Cannot read property 'runtime' of undefined
Uncaught TypeError: Cannot call method 'removeAttribute' of null
这是开启闪光灯的代码,你看一下,记得引用mui.min.js,open_camera_flash.js文件,案例和文件我已经打包在附件里面了,记得下载(ps:附件在最下面)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>开启闪光灯和关闭闪光灯</title>
<link rel="stylesheet" href="css/mui.min.css" />
<script type="text/javascript" src="js/mui.min.js" ></script>
<script type="text/javascript" src="js/open_camera_flash.js" ></script>
<style type="text/css">
p{
width:100%;
height: 60px;
line-height: 60px;
text-align: center;
border:1px red solid;
}
p:active{opacity: .6;}
</style>
</head>
<body>
<p id="p1">开启闪光灯</p>
<p id="p2">关闭闪光灯</p>
<p id="p3">释放资源(界面关闭需释放)</p>
<script>
mui.plusReady(function(){
p1.addEventListener('tap',function(){
if(FlashControl)FlashControl.open();
});
p2.addEventListener('tap',function(){
if(FlashControl)FlashControl.close();
});
p3.addEventListener('tap',function(){
if(FlashControl)FlashControl.release();
});
});
</script>
</body>
</html>
这是我的网站,O(∩_∩)O谢谢支持----->>中旋网ZxlmWeb
那年夏天 (作者)
谢谢
2017-04-28 19:46