我正在使用https://capacitorjs.com/docs/apis/filesystem
取自该站点的示例代码为:
import { Filesystem, Directory, Encoding } from '@capacitor/filesystem';
const writeSecretFile = async () => {
await Filesystem.writeFile({
path: 'secrets/text.txt',
data: "This is a test",
directory: Directory.Documents,
encoding: Encoding.UTF8,
});
};
当我通过Web /ionic serve
运行程序时
在哪里可以找到保存的文件:secrets/text.txt
在我的计算机上?
1条答案
按热度按时间pftdvrlh1#
The plugin's source code (Capacitor v4.0.1) reveals the web plugin tries to use IndexedDB, and fails if IndexedDB is not available.
Check out the initDb() method:
Using the example from the documentation, you can check the result in the Developper tools:
Capacitor uses static names ("DOCUMENTS", "CACHE", "DATA", etc) as the counterpart to native paths for the web.
Note that the fact that it is not explained in the documentation might indicate that the implementation could change at any time.