日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > HTML >内容正文

HTML

两种前端在线json编辑器方案(无法解决number精度丢失问题)

發布時間:2023/12/10 HTML 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 两种前端在线json编辑器方案(无法解决number精度丢失问题) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

解決精度丟失問題,移步我的其他文章

vue-json-editor

1.安裝vue-json-editor

npm install vue-json-editor --save

2.在.vue 文件中引用

import JsonEditor from "vue-json-editor";

3.使用

<template><div class = "routeManagement"><vue-json-editor v-model="routeJson" :showBtns="true" lang="zh"@json-change="onJsonChange" @json-save = "onJsonSave"/></div> </template><script> // 引入vue-json-editor模塊 import vueJsonEditor from 'vue-json-editor' export default {data () {return{// 可使用 JSON.parse() JSON.stringify() 轉化 json 數據json: {msg: 'demo of jsoneditor'}}},components: {vueJsonEditor},methods: {onJsonChange () { // 數據改變時觸發},onJsonSave(){ // 點擊保存觸發}}, } </script><style lang="scss" scoped> .routeManagement{width:98%;margin:16px auto;/deep/.jsoneditor-vue{height:700px;}/deep/.json-save-btn{cursor: pointer;} } </style>

4.效果

codemirror + json-lint

1.安裝

npm install codemirror npm install json-lint

2.組件

<template><div class="json-editor"><textarea ref="textarea" /></div> </template><script> import CodeMirror from 'codemirror' import 'codemirror/addon/lint/lint.css' import 'codemirror/lib/codemirror.css' import 'codemirror/theme/rubyblue.css' require('script-loader!jsonlint') import 'codemirror/mode/javascript/javascript' import 'codemirror/addon/lint/lint' import 'codemirror/addon/lint/json-lint'export default {name: 'JsonEditor',/* eslint-disable vue/require-prop-types */props: ['value'],data() {return {jsonEditor: false}},watch: {value(value) {const editorValue = this.jsonEditor.getValue()if (value !== editorValue) {this.jsonEditor.setValue(JSON.stringify(this.value, null, 2))}}},mounted() {this.jsonEditor = CodeMirror.fromTextArea(this.$refs.textarea, {lineNumbers: true,mode: 'application/json',gutters: ['CodeMirror-lint-markers'],theme: 'rubyblue',lint: true})this.jsonEditor.setValue(JSON.stringify(this.value, null, 2))this.jsonEditor.on('change', cm => {this.$emit('changed', cm.getValue())this.$emit('input', cm.getValue())})},methods: {getValue() {return this.jsonEditor.getValue()}} } </script><style lang="scss" scoped> .json-editor {height: 100%;position: relative;::v-deep {.CodeMirror {height: auto;min-height: 300px;}.CodeMirror-scroll {min-height: 300px;}.cm-s-rubyblue span.cm-string {color: #F08047;}} } </style>

3.使用

先引入組件然后直接用 <JsonEditor ref="jsonEditor" v-model="jsonValue"></JsonEditor>

4.效果圖

總結

以上是生活随笔為你收集整理的两种前端在线json编辑器方案(无法解决number精度丢失问题)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。