这是官方文档的用法:
// Callback from a <input type="file" onchange="onChange(event)">function onChange(event) { var file = event.target.files[0]; var reader = new FileReader(); reader.onload = function(event) { // The file's text will be printed here console.log(event.target.result) }; reader.readAsText(file); }
但如果我想传递一个参数给function(event){}, 应该怎么做,我试过如下定义:
var a = 1; reader.onload = function(event, a) { // The file's text will be printed here console.log(event.target.result) };
12345678_0001
相关分类