如果触发eventListener,如何将参数传递给箭头函数?
system.graph('rec').create()
:remote config alias g rec.g
schema.propertyKey("name").Text().create();
schema.propertyKey("name").properties("name").add();
答案 0 :(得分:1)
让你的fileUpload
返回内部功能
const fileUpload = (certificateName) => (evt) => {
console.log(`Name of Certificate: #{certificateName}`);
let myFile = evt.target.files[0],
maxFileSize = evt.target.getAttribute('data-fileSizeMax');
if(myFile.size <= maxFileSize){
// etc.
}
}
您需要调用fileUpload
函数并传递certificateName
。
currentFileInput.addEventListener('change', fileUpload(certificateName), false);
答案 1 :(得分:1)
您需要将函数调用包装在另一个函数中
let certificateName = document.querySelector('.js--c-name').value;
currentFileInput.addEventListener('change', function(e){
fileUpload(e, certificateName ); //observe changes in this line
}, false);
const fileUpload = (evt, certificateName) => { //pass the arguments
//rest of your code as is
}