“tauri-app/api版本^1.0.2”
日常抽风导致进不去的官方地址https://tauri.app/v1/api/js/modules/fs
fs的权限问题
相关参考https://github.com/tauri-apps/tauri/issues/4130
切记切记,要在这里做修改
修改如图
"fs": {
"scope": ["*"]
}
scope按照我 “自己的理解” 是给予程序操作权限,要是不写,会报错:
中文:配置的作用域上不允许未捕获(承诺中)路径
英文:Uncaught (in promise) path not allowed on the configured scope
其中 ["*"] 代表所有的盘都给予操作权限,
又可以写为,(俺没有试过直接用路径E:/xxx/xxx的方法)
"scope": ["$DATA/*"]
"scope": ["$DESKTOP/*"]
"scope": ["$DESKTOP/**"]
//参考
https://solveforum.com/forums/threads/solved-rust-uncaught-in-promise-path-not-allowed-on-the-configured-scope.1299245/
https://solveforum.com/forums/threads/solved-tauri-window-__tauri__-fs-readdir-is-unable-to-read-directory-error-path-not-allowed-on-the-configured-scope.744611/
fs的调用
import {fs} from '@tauri-apps/api'
加上花括号能更简便的调用里面的方法,如
fs.readTextFile('app.conf', { dir: BaseDirectory.App })
fs.readTextFile(FilePath)
若是不加上
import fs from '@tauri-apps/api'
使用该方法会报错: