Vue.js 2.* jsoneditor Wrapper
Importing:
``
import JSONEditor from 'vue2-jsoneditor'
export default {
name: 'app',
data () {
return {
json: {
foo: 'bar'
}
}
}
methods: {
onChange(newJson) {
// handle json changes
}
}
components: {
JSONEditor
}
}
`
Then you can use it like this in your template:
Note: onChange handler is optional
``
You can also put a ref on the editor to access the JsonEditor object directly:
`
`
if you need, you can access the editor instance like this:
`
const editor = this.$refs.editor.editor // a little redundant, but it does the trick!
editor.set(...) // At this point, you can use the methods available here: https://github.com/josdejong/jsoneditor/blob/master/docs/api.md#methods
`
Vue.js 2 Webpack template was used to generate this project.
` bashinstall dependencies
npm install
For detailed explanation on how things work, checkout the guide and docs for vue-loader.