-
直接写html标签
iPhone 和Android通用
选照片文件<input type="file" accept="image/*"/>
打开摄像头<input type="file" capture /> 或者 <input type="file" capture accept="image/*"/>
-
判断安卓和苹果设备
const agent = navigator.userAgent;
const isAndroid = agent.indexOf('Android') > -1 || agent.indexOf('Linux') > -1; //android终端或者uc浏览器
const isiOS = !!agent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
if(isAndroid){ //如果是安卓
console.log("android");
}else if(isiOS) { //如果是ios
console.log("apple");
}