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

后端 未结 4 961
攒了一身酷
攒了一身酷 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:46

    I have recently started working on a project using Vue JS, JSON Schema. I am trying to access nested JSON Objects from a JSON Schema file in the Vue app. I tried the below code and now I can load different JSON objects inside different Vue template tags. In the script tag add the below code

    import  {JsonObject1name, JsonObject2name} from 'your Json file path';
    

    Now you can access JsonObject1,2 names in data section of export default part as below:

    data: () => ({ 
      
      schema: JsonObject1name,
      schema1: JsonObject2name,   
      
      model: {} 
    }),
    

    Now you can load the schema, schema1 data inside Vue template according to your requirement. See below code for example :

          
            
    
          
          
    

    SchemaForm is the local variable name for @formSchema/native library. I have implemented the data of different JSON objects through forms in different CSS tabs.

    I hope this answer helps someone. I can help if there are any questions.

提交回复
热议问题