vue3-ace-editor前端 json格式化显示 json编辑器使用

本文介绍了如何在Vue3项目中使用vue3-ace-editor插件实现JSON数据的格式化和压缩功能,通过el-select选择主题并配合Vue的响应式特性来操作文本框中的JSON内容。

前端 json格式化显示 json编辑器使用vue3-ace-editor

1.安装
项目目录下打开终端 运行

npm install vue3-ace-editor

2.使用

<template>
    <div class='content'>
        <el-select v-model="aceConfig.theme" class="m-2" placeholder="Select" size="large">
            <el-option v-for="item in aceConfig.arr" :key="item" :label="item" :value="item" />
        </el-select>
        <el-button @click="jsonFormat">格式化</el-button>
        <el-button @click="jsonNoFormat">压缩</el-button>
        <v-ace-editor v-model:value="dataForm.textareashow" @init="jsonFormat" lang="json" :theme="aceConfig.theme"
                      :options="aceConfig.options" :readonly="aceConfig.readOnly" style="height:300px;margin-top: 20px;" class="ace-editor" />
    </div>
</template>

<script setup>
import {
   
    reactive } from 'vue'
import {
   
    VAceEditor } from 'vue3-ace-editor';

//import "ace-builds/webpack-resolver";
// 加了这个【import "ace-builds/webpack-resolver";】可能会报错
//(若报错 则需要安装node.js的一个包 就是主题)
// 命令:npm install --save-dev file-loader

import 'ace-builds/src-noconflict/mode-json';
import 
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值