Get a local json file on NativeScript

后端 未结 4 808
伪装坚强ぢ
伪装坚强ぢ 2021-01-18 07:29

How to get a local big json data?

I have tried this, but I had no success:

var sa = require(\"./shared/resources/sa.json\");
var array = new observab         


        
4条回答
  •  迷失自我
    2021-01-18 08:25

    TypeScript:

    import {knownFolders} from "tns-core-modules/file-system";
    
    export class Something {
        loadFile() {
            let appFolder = knownFolders.currentApp();
            let cfgFile = appFolder.getFile("config/config.json");
            console.log(cfgFile.readTextSync());
        }
    }
    

提交回复
热议问题