Vue component that renders JSON data in a collapsible tree structure.
<json-tree>
component.<script src="https://unpkg.com/vue@2.6.10/dist/vue.min.js"></script>
<script src="https://unpkg.com/vue-json-tree@0.4.1/dist/json-tree.js"></script>
<div id="app"></div>
<script>
new Vue({
template: '<json-tree :raw="sample"></json-tree>',
el: '#app',
data: {
sample: '{"foo": "bar"}'
}
})
</script>
vue-json-tree
package via NPM.npm install --save vue-json-tree
import JsonTree from 'vue-json-tree'
Vue.component('json-tree', JsonTree)
raw
(string
, optional)The data you want to present in the tree view. Must be a valid JSON string, otherwise it fails.
data
(any
, optional)If your JSON data has already been parsed, bind this one instead. Must be something that can be produced by JSON.parse()
.
level
(number
, optional)Sometimes the data structure is very deep. You could set them to collapsed on load. By default all levels are expanded.
https://myst729.github.io/vue-json-tree/
MIT © Leo