注意传的是event
function previewImage(file, status, index,evt) {
// 预览图
readFiles(evt,index);
console.log(evt);
}
function readFiles(evt,index) {
//
(“canvas”).remove();
(
“
c
a
n
v
a
s
”
)
.
r
e
m
o
v
e
(
)
;
(‘.mn_up .smallimg’).remove();
console.log(evt);
var files = evt.target.files;
if (!files) {
alert(“文件不支持”);
return;
}
var imgele = new Image();
var thesrc = window.URL.createObjectURL(files[0]);
imgele.src = thesrc;
imgele.onload = function() {
var canvas = document.createElement(“canvas”);
canvas.setAttribute(“id”,”pic_”+index);
canvas.setAttribute(“width”, “80px”);
canvas.setAttribute(“height”, “80px”);
canvas.setAttribute(“onclick”, “delsuonue(this,”+index+”)”)
canvas.innerHTML = “你的浏览器不支持”;
var imgs = document.getElementById(“mn_up”);
imgs.appendChild(canvas);
var cxt = canvas.getContext(“2d”);
//绘图
cxt.drawImage(this, 0, 0, 80, 80);
}
}