之前做的wex5页面关于图片的上传裁剪,测试的时候发现在苹果手机上不能触发(但是按住在松开是可以的),进过长时间的探索终于找到了办法。
代码如下
<input type="file" value="" xid="inputImage" bind-change="file1Change"
accept="image/*" style="display:none;"/>
<div component="$UI/system/components/justep/row/row" class="x-row" xid="row1" id="top1">
<div class="x-col" xid="col1"/>
<div class="x-col x-col-fixed x-col-center" xid="col2" style="width:200px;">
<div xid="div1" class="img-preview" id="preview" style="position:relative;left:35px;"/>
<div> <a component="$UI/system/components/justep/button/button" class="btn btn-link btn-only-icon" id="shangchuan"
label="图片上传" xid="button1" onClick="button1Click" icon="icon-android-search" style="position:relative;left:40px;font-size:medium;">
<i xid="i1" class="icon-android-search"/>
图片上传
</a> </div>
</div>
<div class="x-col" xid="col3"/>
</div>
js代码:
Model.prototype.button1Click = function(event) {
this.comp("button2").set({
"disabled" : false
});
var u = navigator.userAgent;
var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); // ios终端
$(this.getElementByXid('inputImage')).click();
if (isIOS) {
timer = setTimeout(function() {
}, 2000); // 时间 2s
$(this.getElementByXid('inputImage')).click();
}
};
然后在苹果上点击就是可以的了。