W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
open(: ?OpenDialogOptions
?Since: 1.0.0Since: 1.0.0): ?Promise
?< | |options?nullstring string[]>
打開文件/目錄選擇對話框。
所選路徑將添加到文件系統(tǒng)和資產(chǎn)協(xié)議允許列表范圍。 當(dāng)安全性比此 API 的易用性更重要時, 最好編寫專用命令。
請注意,允許列表范圍更改不會保留,因此在重新啟動應(yīng)用程序時會清除這些值。 您可以使用 ?tauri-plugin-persisted-scope
? 將其保存到文件系統(tǒng)中。
例
import { open } from '@tauri-apps/api/dialog';
// Open a selection dialog for image files
const selected = await open({
multiple: true,
filters: [{
name: 'Image',
extensions: ['png', 'jpeg']
}]
});
if (Array.isArray(selected)) {
// user selected multiple files
} else if (selected === null) {
// user cancelled the selection
} else {
// user selected a single file
}
例
import { open } from '@tauri-apps/api/dialog';
import { appDir } from '@tauri-apps/api/path';
// Open a selection dialog for directories
const selected = await open({
directory: true,
multiple: true,
defaultPath: await appDir(),
});
if (Array.isArray(selected)) {
// user selected multiple directories
} else if (selected === null) {
// user cancelled the selection
} else {
// user selected a single directory
}
Since: 1.0.0
參數(shù)
名字 | 類型 |
---|---|
options | OpenDialogOptions |
Returns: ?Promise
?< | |null
string
string
[]>
解析到所選路徑的 promise
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: