当前位置: 首页 > news >正文

前端编辑器JSON HTML等,vue2-ace-editor,vue3-ace-editor

与框架无关
vue2-ace-editor有问题,ace拿不到(brace)
一些组件都是基于ace-builds或者brace包装的
不如直接用下面的,不如直接使用下面的
在这里插入图片描述

<template><div ref="editor" class="json-editor"></div>
</template><script>
import ace from 'ace-builds';
import 'ace-builds/webpack-resolver'; // 确保 Webpack 正确解析模块
import 'ace-builds/src-noconflict/mode-json'; // 引入 JSON 模式
import 'ace-builds/src-noconflict/theme-monokai'; // 引入 Monokai 主题export default {name: 'JsonEditor',props: {value: {type: String,default: '',},},data() {return {editor: null,};},watch: {value(newValue) {if (newValue !== this.editor.getValue()) {this.editor.setValue(newValue, 1); // 1 表示不触发 change 事件}},},mounted() {this.initEditor();},beforeDestroy() {if (this.editor) {this.editor.destroy();this.editor = null;}},methods: {initEditor() {this.editor = ace.edit(this.$refs.editor, {mode: 'ace/mode/json',theme: 'ace/theme/monokai',tabSize: 2,useWorker: false, // 禁用 worker 以避免 JSON 解析错误时的警告minLines: 10,maxLines: 30,fontSize: '14px',showPrintMargin: false,});this.editor.setValue(this.value, 1); // 初始化值this.editor.getSession().on('change', () => {this.$emit('input', this.editor.getValue());});},},
};
</script><style scoped>
.json-editor {width: 100%;height: 400px;
}
</style>

解决光标错位

.ace_editor,
.ace_editor * {font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Droid Sans Mono', 'Consolas', monospace !important;font-size: 12px !important;font-weight: 400 !important;letter-spacing: 0 !important;
}
http://www.lryc.cn/news/503323.html

相关文章:

  • C++ 中的运算符重载
  • 渗透测试工具 -- SQLmap安装教程及使用
  • 使用 Database Tools 实现高效数据查询的十大 IntelliJ IDEA 快捷键
  • SpringBoot 整合 RabbitMQ 实现流量消峰
  • 大数据挖掘建模平台案例分享
  • MySQL数据表的管理
  • SpringBoot【十三(实战篇)】集成在线接口文档Swagger2
  • 【C++初阶】第8课—标准模板库STL(string_2)
  • 【arm】程序跑飞,SWD端口不可用修复(N32G435CBL7)
  • https证书生成、linux 生成https证书、nginx 配置https证书
  • Halcon随机贴图生成缺陷图片脚本
  • [ZMQ] -- ZMQ通信Protobuf数据结构 1
  • 大数据平台
  • 《C++解锁机器学习特征工程:构建智能数据基石》
  • 《机器学习》3.7-4.3end if 启发式 uci数据集klda方法——非线性可分的分类器
  • 【Linux】VMware 安装 Ubuntu18.04.2
  • 人员离岗监测摄像机智能人员睡岗、逃岗监测 Python 语言结合 OpenCV
  • 【Spark】Spark数据倾斜解决方案、大表join小表及大表join大表优化思路
  • 探索 Cesium 的未来:3D Tiles Next 标准解析
  • 每日一站技術架構解析之-cc手機桌布網
  • prometheus监控之黑盒(blackbox)监控
  • 计算机网络之传输层协议TCP
  • 子查询与嵌套查询
  • GPT-SoVITS语音合成模型部署及使用
  • springboot423玩具租赁系统boot(论文+源码)_kaic
  • 【收藏】Cesium 限制相机倾斜角(pitch)滑动范围
  • Jenkins流水线初体验(六)
  • Azure OpenAI 生成式人工智能白皮书
  • Ubuntu22.04安装docker desktop遇到的bug
  • LLMC:大语言模型压缩工具的开发实践