surmon-china / vue-codemirror

@codemirror code editor component for @vuejs
https://github.surmon.me/vue-codemirror
MIT License
3.28k stars 382 forks source link

when change the input value, the doc of state does not update #204

Open GongJS opened 1 year ago

GongJS commented 1 year ago

Describe the bug

this is my code:

<button @click="changeCode">change</button>
<Codemirror
      v-model="code"
      :indent-with-tab="true"
      :tab-size="2"
      @ready="handleReady"
/>

const code = ref('{}')
const state = ref()

const handleReady = (payload) => {
    state.value = payload.state
    console.log( state.value.doc)
}

const changeCode = () => {
    code.value = '{"a": "1"}'
    console.log(state.value.doc)
   // state.value.doc dose not change
}

### Reproduction

if need, i will provide

### System Info

```shell
"vue-codemirror": "^6.1.1"

Used Package Manager

pnpm

Validations