web下怎么打开目录选择器

开始使用了input的文件选择器,但是这样目标选择文件夹的时候,onchange里只能通过文件夹下第一个文件的路径来判断文件夹的路径,这样的话如果选中的是个空文件夹,onchange甚至可能不会触发,所以我认为这种方法可能不太可行,还是需要打开目录选择器来实现这个功能。目前使用的代码: let inputEl: HTMLInputElement = document.getElementById(‘file_input’);
if (!inputEl) {

        inputEl = document.createElement('input');
        inputEl.id = 'file_input';
        inputEl.setAttribute('id', 'file_input');
        inputEl.setAttribute('type', 'file');
       
        inputEl.style.opacity = '0';
        inputEl.style.position = 'absolute';
        inputEl.setAttribute('left', '-999px');
        document.body.appendChild(inputEl);
    }

  
    inputEl.setAttribute('webkitdirectory', "");
   
    
    inputEl.onchange = (event) => {
        
        let files = inputEl.files;
        if (files && files.length > 0) {
            var file = files[0];
           console.log(this.stringifyPath(file.path))
           this.exidChange(this.stringifyPath(file.path));
        }
    }
    inputEl.click();

已解决,自己做了个目录选择器