文章只是记录使用该插件的过程:

<template>
    <div class="json-editor">
    <textarea ref="textarea" />
  </div>
</template>
/**
导入对应的包
import .....
**/
// 创建
this.jsonEditor = CodeMirror.fromTextArea(this.$refs.textarea, {
      lineNumbers: true,
      mode: 'application/json',
      gutters: ['CodeMirror-lint-markers'],
      theme: 'rubyblue',
      lint: true,
      readOnly: true // 只读
    })

// 销毁
this.jsonEditor.getWarpperElement().parentNode.removeChild(this.jsonEditor.getWarpperElement())

kkw凯凯王
42 声望2 粉丝