vue项目引入代码编辑器

import Editor from 'vue2-ace-editor'

 components: { Editor }, 

 1.模板使用

<el-drawer title="代码编辑器" :visible.sync="htmlDialog" direction="rtl" :before-close="handleHtmlClose">
                <div class="codeEditBox">
                    <editor :lang="langs" v-model="formatHtml" @input='codeChange' :options="editorOptions" @init="editorInit" :theme="theme"></editor>
                </div>
                <div>
                    <el-button type="primary" @click="htmlHandle">确定</el-button>
                </div>
            </el-drawer>

 2.配置信息

editorOptions: {
                    // 设置代码编辑器的样式
                tabSize: 4, // tab默认大小
                showPrintMargin: false, // 去除编辑器里的竖线
                fontSize: 20, // 字体大小
                highlightActiveLine: true, // 高亮配置
                enableBasicAutocompletion: true, //启用基本自动完成
                enableSnippets: true, // 启用代码段
                enableLiveAutocompletion: true, // 启用实时自动完成
            },
            theme: 'monokai',
            langs: 'html',

3.主题设置

editorInit () {
            require('brace/ext/language_tools') // language extension prerequsite...
            require(`brace/mode/${this.langs}`) // 语言
            require(`brace/theme/${this.theme}`) // 主题
        },

 

相关推荐

  1. vue项目引入代码编辑器

    2024-04-10 15:56:02       15 阅读
  2. vue2-ace-editor实现一个简单的代码编辑器

    2024-04-10 15:56:02       32 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-04-10 15:56:02       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-04-10 15:56:02       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-04-10 15:56:02       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-04-10 15:56:02       18 阅读

热门阅读

  1. 19、差分矩阵

    2024-04-10 15:56:02       12 阅读
  2. 蓝牙notify和indicate消息区别

    2024-04-10 15:56:02       13 阅读
  3. Unity之C#面试题(一)

    2024-04-10 15:56:02       11 阅读
  4. gin+sse实现离散的消息通知

    2024-04-10 15:56:02       14 阅读
  5. 安装 FFmpeg

    2024-04-10 15:56:02       11 阅读
  6. this::onCheckedChanged

    2024-04-10 15:56:02       12 阅读
  7. spring test配合junit4 实现单元测试

    2024-04-10 15:56:02       11 阅读