2017-01-18 5 views
0

코드 분석 도구를 만들었으며 json 데이터를 vue 테이블에 설정하려고합니다. 그러나 json Key가 필요합니다. 이는 패키지/파일 이름을 표시 할 데이터의 디렉토리입니다. 여기 Vue.js 알 수 없음 vson에 대한 Json 키

는 JSON 부분입니다 (NULLY이 패키지) :

"folderStatistics": { 
      "NULLY": { 
      "Statistiken": { 
       "Werte": { 
       "Felder": "0", 
       "Konstruktoren": "0", 
       "Methoden": "8", 
       "Klassen": "1", 
       "Codezeilen": "191" 
       } 
      }, 

는이 내 HTML입니다 : "NULLY"와

<table class="table table-bordered"> 
     <thead> 
     <tr> 
     <th></th> 
     <th>Felder</th> 
     <th>Konstruktoren</th> 
     <th>Methoden</th> 
     <th>Klassen</th> 
     <th>Codezeilen</th> 
     </tr> 
     </thead> 
     <tbody> 
     <tr v-for="value in folderStatistics.NULLY.Statistiken"> 
     <td>{{$key}}</td> 
     <td>{{value.Felder}}</td> 
     <td>{{value.Konstruktoren}}</td> 
     <td>{{value.Methoden}}</td> 
     <td>{{value.Klassen}}</td> 
     <td>{{value.Codezeilen}}</td> 
     </tr> 
     </tbody> 

,이 디렉토리를 작동하지만 NULLY이 있어야한다 동적. 어떻게 만들 수 있습니까? 그것도 작동합니까?

답변

1

documentation

당신은 변수에 NULLYpackage을 말하고 다음과 같이보기로 사용할 수 있습니다

<tbody> 
    <tr v-for="(value, key) in folderStatistics[package].Statistiken"> 
    <td>{{key}}</td> 
    <td>{{value.Felder}}</td> 
    <td>{{value.Konstruktoren}}</td> 
    <td>{{value.Methoden}}</td> 
    <td>{{value.Klassen}}</td> 
    <td>{{value.Codezeilen}}</td> 
    </tr> 
    </tbody> 

데모 fiddle합니다.

+0

그래, 그렇지만 NULLY는 패키지의 이름이고 다른 업로드 된 패키지를 모듈화하고 싶습니다. –

+0

@FreshmanCrazy_Guy 업데이트 된 답변을 확인하십시오. – Saurabh