【问题标题】:How to make a choose file action in Chonky.js如何在 Chonky.js 中进行选择文件操作
【发布时间】:2021-02-26 03:34:34
【问题描述】:

我正在使用 Chonky 库为我的应用创建文件资源管理器。

我需要一种方法来选择文件并在双击时检索其 id

            const [files, setFiles] = useState(() => [{ id: "1", name: "index.html" }]);

            <FileBrowser
              files={files}
              fileActions={fileActions}
              onFileAction={handleFileAction}
              clearSelectionOnOutsideClick={true}
              thumbnailGenerator={(file) => (file.url ? file.url : null)}
            >
              <FileToolbar />
              <FileSearch />
              <FileList />
            </FileBrowser>

【问题讨论】:

    标签: javascript html reactjs web shared-libraries


    【解决方案1】:

    所以比较容易

    你需要做的是:

    将此笨拙的动作类型添加到您的 fileActions 数组中:

    () => [
          ChonkyActions.ChangeSelection,
        ],
     
    

    然后在你的 handleFileAction 函数中添加一个逻辑检查

    if (action.id === ChonkyActions.ChangeSelection) {
      //Do something..
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-12-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-22
      • 1970-01-01
      相关资源
      最近更新 更多