Angular 6 - Load JSON from local

前端 未结 9 2555
南笙
南笙 2020-12-14 04:26

I am trying to load a local JSONfile of two ways.

This is my json file:

{
  \"imgsesion\": \"fa_closesesion.png\",
  \"texthome\": \"volver a la home         


        
9条回答
  •  醉话见心
    2020-12-14 04:47

    By this way...

    import "file" from "./file.json" 
    

    I got red line and got error like module not found by angular.

    After some RND I got another way which works for me. Hope it may help someone.

    var data = require('src/file.json');
    console.log("Json data : ", JSON.stringify(data));
    

提交回复
热议问题