Created
February 17, 2017 18:49
-
-
Save arvidkahl/7d1c9b317d07f2700231eb35d212e812 to your computer and use it in GitHub Desktop.
JSON Tree View Basic HTML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container" id="vue-root"> | |
<div class="row"> | |
<div class="col-xs-12"> | |
<h1>A JSON Tree View Component in Vue.js</h1> | |
</div> | |
</div> | |
<div class="row"> | |
<div class="col-xs-6"> | |
<pre><code>{{formatJSON(sampleData)}}</code></pre> | |
</div> | |
<div class="col-xs-6">[Tree View]</div> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new Vue({ | |
el: "#vue-root", | |
methods: { | |
// return pretty-printed JSON | |
formatJSON: function(theJSON){ | |
return JSON.stringify(theJSON, true, 2); | |
} | |
}, | |
data: function(){ | |
return { | |
// Returns a JSON object with common | |
// data structures, such as Arrays, | |
// Objects and raw Values | |
sampleData: {"a":"b","c":[{"a":"b"},{"c":"d","e":"f"}],"d":{"a":"b","c":1234,"d":[1,"a",{"c":"d"}]},"g":null,"h":3.1415} | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment