joaomede / vue3-json-editor

A jsoneditor of vue 3 (next) - (fork vue-json-editor)
ISC License
45 stars 29 forks source link

when I use vue3-json-editor I got a error TypeError: Cannot read property 'getMode' of null #9

Closed jianshe closed 2 years ago

jianshe commented 3 years ago

Cannot read property 'getMode' of null Please help me to deal with it .

Thank you. joaomede

joaomede commented 3 years ago

please, show your implementation

juanfriss commented 3 years ago

Just importing this got me the same error.

joaomede commented 3 years ago

Guys, @juanfriss, @jianshe, there are example implementations in the repository itself, please test the examples. https://github.com/joaomede/vue3-json-editor/blob/master/src/App.vue

https://github.com/joaomede/vue3-json-editor/blob/master/example_vite/App.vue

linqinghao commented 3 years ago

got the same error

dylantientcheu commented 3 years ago

Hello, i have been having this error too. This is a screenshot of the link to the code that shows up on the error

image

joaomede commented 3 years ago

To test with "vite", run the command "npm run dev vue" to test with "Vue3", run the command "npm run dev" Currently I haven't identified any problems in the examples in the project, please use the examples to test the cases.

ekxs0109 commented 3 years ago

image

image

same error

wellingtonfetchly commented 2 years ago

Screen Shot 2022-01-28 at 17 44 36 Same error here just on production

This is my code

<template>
  <div>
    <Vue3JsonEditor v-model="json" mode="code" @json-change="onJsonChange" @has-error="handleError" />
    <p v-show="errorMessage" v-html="errorMessage" class="input-error" />
  </div>
</template>

<script>
import { reactive, toRefs, ref } from 'vue'
import { useField } from 'vee-validate'
import { Vue3JsonEditor } from 'vue3-json-editor'
export default {
  components: {
    Vue3JsonEditor
  },
  props: {
    name: {
      type: String,
      required: true
    }
  },
  setup (props) {
    const {
      value: inputValue,
      handleChange
    } = useField(props.name)

    const state = reactive({
      json: inputValue || {}
    })

    const errorMessage = ref(null)

    function handleError(error) {
      errorMessage.value = error 
    }

    function onJsonChange(value) {
      handleChange(value)
      errorMessage.value = null
    }

    return {
      ...toRefs(state),
      onJsonChange,
      handleError,
      errorMessage
    }
  }
}
</script>
hakuna0829 commented 2 years ago

I've got same error. I've created new project using quasar with vue 3.0 cli and followed readme from vue3-json-editor package like above. Is there any solution?

wellingtonfetchly commented 2 years ago

The problem was already solved in this commit fixed gitMode null bug, but the file dist/vue3-json-editor.esm.js in node_modules is still with the old code Screen Shot 2022-01-31 at 10 28 36

hakuna0829 commented 2 years ago

Thanks @wellingtonfetchly. Then, what shall I do? Need to change it inside node_moudles?

wellingtonfetchly commented 2 years ago

Hey @hakuna0829, I'm not sure either, I'm having the same problem.

wellingtonfetchly commented 2 years ago

It worked for me to update vue version to 3.2.29

tripflex commented 2 years ago

Yeah same issue/error using 3.0.0 (yes i know it's outdated but can't update right now without creating a bunch of other issues).

Using 1.1.4 from npm

tripflex commented 2 years ago

image @wellingtonfetchly is correct, it seems the vue3-json-editor.esm.prod.js file does NOT have the updated codebase.

@joaomede did something get messed up during build and push to npm that these files were not updated with latest commits? Not sure why this is marked as wont fix

joaomede commented 2 years ago

Fixed: https://github.com/joaomede/vue3-json-editor/commit/2112d928b28268be2412e4f68eb65cd02d09309e NPM: https://www.npmjs.com/package/vue3-json-editor/v/1.1.5