How to acces external json file objects in vue.js app

后端 未结 4 952
攒了一身酷
攒了一身酷 2020-12-04 15:30

How to access JSON objects in the vue.js app I am new in this

import json from \'./json/data.json\'

the JSON fil

4条回答
  •  执笔经年
    2020-12-04 15:38

    Typescript projects (I have typescript in SFC vue components), need to set resolveJsonModule compiler option to true.

    In tsconfig.json:

    {
      "compilerOptions": {
        ...
        "resolveJsonModule": true,
        ...
      },
      ...
    }
    

    Happy coding :)

    (Source https://www.typescriptlang.org/docs/handbook/compiler-options.html)

提交回复
热议问题