Here are two ways to trigger an input click on ios:

Method one: <label class="upload"> <label > <input type="file" class="sr-only" id="inputImage" name="file" Accept ="image/*"> </label> Method 2: <div @click="startRecord()" class="face-link-btn"> Start recording </div> <label class="upload" ref=" starTtest "> <input v-show="false" id="imgFile" ref="startReal" accept="video/*" type="file" capture="user" @change="uploadVideo()" /> </label>Copy the code

And then I used the second method, and then I ran into the second problem that I couldn’t trigger after I sent the request, so I made a note.

1. This cannot be triggered

startRecord () { $.ajax({ url: 'www.baidu.com', dataType: 'json', data: params, timeout: 10000, headers: { "Content-Type": 'application/x-www-form-urlencoded' }, success: (res) => { if (res && res.code === 'SUC00000') { this.$refs.starttest.click(); } else {}}, error: function (err) {console.log(err); }}); }Copy the code

2. Can trigger (mainly add synchronous processing and call outside (call inside the request does not take effect)

startRecord () { let uploadflag = false $.ajax({ url: 'www.baidu.com', dataType: 'json', data: params, async: False, (must) timeout: 10000, headers: {" content-type ": 'application/x-www-form-urlencoded'}, success: (res) => { if (res && res.code === 'SUC00000') { uploadflag = true; } else {} }, error: function (err) { console.log(err); }}); if (uploadflag) { this.$refs.starttest.click(); }}Copy the code

That’s all for recording this question. It was also the first time to publish an article. Little experience and a lot of attention.