Vue數據格式化:JSON、HTML、XML數據的格式化顯示

介紹

數據格式化編輯器: 方便你實現在線的數據格式化編輯與顯示的工具。支持的數據格式包括:JSON、HTML、XML

源碼工程地址:vue_data_editor

效果圖

在這裏插入圖片描述

安裝

由於源碼未創建npm包,所以請手動下載工具源碼使用,謝謝!~

使用方式

import VueDataEditor from './vue_data_editor'

export default {
  name: 'ace_index',
  data: () => ({
    json_value: "{\"q\":\"百度\",\"p\":false,\"g\":[{\"type\":\"sug\",\"sa\":\"s_1\",\"q\":\"百度翻譯\"},{\"type\":\"sug\",\"sa\":\"s_2\",\"q\":\"百度地圖\"},{\"type\":\"sug\",\"sa\":\"s_3\",\"q\":\"百度網盤\"},{\"type\":\"sug\",\"sa\":\"s_4\",\"q\":\"百度識圖\"},{\"type\":\"sug\",\"sa\":\"s_5\",\"q\":\"百度新聞\"},{\"type\":\"sug\",\"sa\":\"s_6\",\"q\":\"百度視頻\"},{\"type\":\"sug\",\"sa\":\"s_7\",\"q\":\"百度搜題\"},{\"type\":\"sug\",\"sa\":\"s_8\",\"q\":\"百度一下\"},{\"type\":\"sug\",\"sa\":\"s_9\",\"q\":\"百度手機衛士隱私保護專版\"},{\"type\":\"sug\",\"sa\":\"s_10\",\"q\":\"百度小說\"}],\"slid\":\"2268943525663350670\"}",
    xml_value: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><project xmlns=\"http://maven.apache.org/POM/4.0.0\"         xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"         xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">    <build>        <plugins>            <plugin>                <groupId>org.mybatis.generator</groupId>                <artifactId>mybatis-generator-maven-plugin</artifactId>                <version>1.3.2</version>                <configuration>                    <configurationFile>src/main/resources/generatorConfig.xml</configurationFile>                    <verbose>true</verbose>                    <overwrite>true</overwrite>                </configuration>            </plugin>        </plugins>    </build></project>",
    html_value: "<!DOCTYPE html><html>  <head>    <meta charset=\"utf-8\">    <meta name=\"viewport\" content=\"width=device-width,initial-scale=1.0\">    <title>kb-vue-components</title>  </head>  <body>    <div id=\"app\"></div>    <!-- built files will be auto injected -->  <script type=\"text/javascript\" src=\"/app.js\"></script></body></html>",
  }),
  render(h) {
    return h('div', {
      staticClass: 'q-pa-sm'
    }, [
      h('div', {
        staticClass: 'text-left text-tertiary font-14 text-weight-bold'
      }, [
        'JSON數據格式顯示效果:'
      ]),
      h(VueDataEditor, {
        on: {
          input: (v) => {
            this.json_value = v
          }
        },
        props: {
          value: this.json_value,
          disable: false,
          width: '100%',
          height: '400px'
        }
      }),

      h('div', {
        staticClass: 'row no-wrap q-mt-md'
      }, [
        h('div', {
          staticClass: 'q-pr-sm',
          style: {
            width: '50%'
          }
        }, [
          h('div', {
            staticClass: 'text-left text-tertiary font-14 text-weight-bold'
          }, [
            'XML數據格式顯示效果:'
          ]),
          h(VueDataEditor, {
            props: {
              value: this.xml_value,
              disable: true,
              height: '400px'
            }
          }),
        ]),
        h('div', {
          staticClass: 'q-pl-sm',
          style: {
            width: '50%'
          }
        }, [
          h('div', {
            staticClass: 'text-left text-tertiary font-14 text-weight-bold'
          }, [
            'HTML數據格式顯示效果:'
          ]),
          h(VueDataEditor, {
            props: {
              value: this.html_value,
              disable: true,
              height: '400px'
            }
          })
        ])
      ])

    ])
  }
}


插件列表

插件地址:brace

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章