H5-安卓和ios调用相机和相册

<input v-if="ipshow" type="file" accept="image/*" name="file1" capture="camera" @change="upload">
<input v-else type="file" accept="image/*" name="file1" @change="upload">
data() {
        return{
                 ipshow:false,//切换input属性
              }
       },
//判断是否ios,是则不执行,否则安卓执行
if ('andriod' == this.appSource()) {
        this.ipshow = true;
 }else{
        this.ipshow = false;
 }
//判断ios和安卓
appSource() {
             const u = navigator.userAgent;
             const isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
             if (isiOS) {
               return "ios";
             } else {
               return "andriod";
           }
},

猜你喜欢

转载自www.cnblogs.com/edczjw-Edison/p/12373507.html