Blame view

src/views/components-demo/json-editor.vue 1.49 KB
d7d9c38c2   Adam   auto commit the c...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
  <template>
    <div class="components-container">
      <aside>Json-Editor is base on <a href="https://github.com/codemirror/CodeMirror" target="_blank">CodeMirrorr</a>. Lint
        base on <a
          href="https://github.com/codemirror/CodeMirror/blob/master/addon/lint/json-lint.js"
          target="_blank"
        >json-lint</a>.</aside>
      <div class="editor-container">
        <json-editor ref="jsonEditor" v-model="value" />
      </div>
    </div>
  </template>
  
  <script>
  import JsonEditor from '@/components/JsonEditor'
  
  const jsonData = '[{"items":[{"market_type":"forexdata","symbol":"XAUUSD"},{"market_type":"forexdata","symbol":"UKOIL"},{"market_type":"forexdata","symbol":"CORN"}],"name":""},{"items":[{"market_type":"forexdata","symbol":"XAUUSD"},{"market_type":"forexdata","symbol":"XAGUSD"},{"market_type":"forexdata","symbol":"AUTD"},{"market_type":"forexdata","symbol":"AGTD"}],"name":"贵金属"},{"items":[{"market_type":"forexdata","symbol":"CORN"},{"market_type":"forexdata","symbol":"WHEAT"},{"market_type":"forexdata","symbol":"SOYBEAN"},{"market_type":"forexdata","symbol":"SUGAR"}],"name":"农产品"},{"items":[{"market_type":"forexdata","symbol":"UKOIL"},{"market_type":"forexdata","symbol":"USOIL"},{"market_type":"forexdata","symbol":"NGAS"}],"name":"能源化工"}]'
  
  export default {
    name: 'JsonEditorDemo',
    components: { JsonEditor },
    data() {
      return {
        value: JSON.parse(jsonData)
      }
    }
  }
  </script>
  
  <style scoped>
  .editor-container{
    position: relative;
    height: 100%;
  }
  </style>