JSONEditor, Vue and Vuex
As I post here I wanted to use JSONEditor as a component. But with Vuex I was able to reduce the work quite a ton. Here is my store for the json_field:
export default {
state: {
json_field: null,
},
getters: {
json_field: state => {
return state.json_field;
}
},
mutations: {
jsonField(state, json_field) {
state.json_field = json_field;
}
},
};
Then my JSONEditor.vue component:
<template>
<div id="jsoneditor" ref="editor"></div>
</template>
<script>
import JSONEditor from 'jsoneditor';
import { mapGetters } from 'vuex'
export default Vue.