注意 :img 的 onload事件是异步执行的!如果你想限制图片的大小和宽高,就需要设置attachmentSimple默认不自动上传:http://docs.wex5.com/wex5-ui-question-list-2105 在 onload 事件中调用self.comp('attachmentSimple1').uploader.submit(); 进行上传
Model.prototype.model1Load = function(event) { var data = this.comp("data1"); var uploader = this.comp("attachmentSimple1").uploader; $(uploader.inputElement).attr('multiple', 'multiple'); var _URL = window.URL || window.webkitURL; uploader.on('onFileSelected', function(event) { var file = event.file, img; if (file) { img = new Image(); img.onload = function () { alert(this.width); alert(this.height); alert(file.size); }; img.src = _URL.createObjectURL(file); } }); };
评一波