package.json

{
"name": "vue-cli",
"version": "1.0.0",
"description": "A Vue.js project",
"author": "lizhi@camelotchina.com",
"private": true,
"scripts": {
...
},
"dependencies": {
...
},
"devDependencies": {
...

"brace": "^0.11.0",
"emmet": "git+https://github.com/cloud9ide/emmet-core.git",
...
},
"engines": {
...
},
"browserslist": [
...
]
}

component文件夹——>editor.vue文件

<template>
  <div style="width: 100%;height: 330px"></div>
</template>

<script>
  require(['emmet/emmet'], function (data) {
    window.emmet = data.emmet
  });
const ace = require('brace');
export default {
  name: 'editor',
  props: {
    value: {
      type: String,
      required: true
    }
  },
  data () {
    return {
      editor: null,
      contentBackup: ''
    }
  },
  watch: {
    value (val) {
      if (this.contentBackup !== val) {
        this.editor.setValue(val, 1)
      }
    },
    theme: function (newTheme) {
      this.editor.setTheme('ace/theme/' + newTheme)
    },
    lang: function (newLang) {
      this.editor.getSession().setMode('ace/mode/' + newLang)
    }
  },
  mounted () {
    let vm = this
    require('brace/ext/emmet')
    require('brace/ext/language_tools')
    let editor = vm.editor = ace.edit(this.$el)
    this.$emit('init', editor)
    let staticWordCompleter = {
      getCompletions: function (editor, session, pos, prefix, callback) {
        vm.$emit('setCompletions', editor, session, pos, prefix, callback)
      }
    }
    editor.completers = [staticWordCompleter]
    editor.setOptions({
      enableBasicAutocompletion: true,
      enableLiveAutocompletion: true
    })
    editor.$blockScrolling = Infinity
    editor.setFontSize(16)
    editor.setOption('enableEmmet', true)
    editor.getSession().setMode('ace/mode/mysql')
    editor.setTheme('ace/theme/xcode')
    editor.setValue(this.value, 1)
    editor.on('change', function () {
      let content = editor.getValue()
      vm.$emit('input', content)
      vm.contentBackup = content
    })
  }
}
</script>

<style scoped>
</style>

view文件夹的 你的页面文件

<editor v-model="formDynamic" @init="editorInit" @setCompletions="setCompletions"></editor>

methods:{
  editorInit(){
    require('brace/mode/mysql')
    require('brace/theme/xcode')
  },
  setCompletions (editor, session, pos, prefix, callback) {//自动提示方法
    callback(null, this.wordList.map(function (word) {
      return {
        caption: word.vl,
        value: word.vl,
        meta: word.meta
      }
    }))
  },
}

mounted(){
  if(!!configHighlight){//输入提示
    for (let i of configHighlight.split('|')) {
      this.wordList.push({'vl': i, 'meta': '关键字'})
    }
  }
}

最新文章

  1. CSharpGL(15)用GLSL渲染2种类型的文字
  2. byte[] 转成图片方法
  3. JSON与XML的区别比较
  4. 关于IONIC 报错 XX is not a function
  5. Linux系统的初化始配置(包括配置网络,修改主机名,关闭firewalld与selinux的生效)
  6. Android的Notification使用注意事项
  7. Javascript: 从prototype漫谈到继承(2)
  8. eclipse提示:This tag and its children can be replaced by one &lt;TextView/&gt; and a compound drawable
  9. 智能车学习(五)&mdash;&mdash; dac学习
  10. Poj 2528 Mayor&#39;s posters 分类: Brush Mode 2014-07-23 09:12 84人阅读 评论(0) 收藏
  11. 登录超时自动退出,计算时间差-b
  12. CMakeLists实战解读--YouCompleteMe
  13. 速度 Github
  14. web组件工具之获取表单数据:webUtils
  15. 指针变量的*p,p以及&amp;p的区别
  16. 一、JavaSE语言概述
  17. AVAudioPlayer与MPMusicPlayerController的区别
  18. ASP.NETCore的Kestrel服务器
  19. WPF中的ObservableCollection数据绑定
  20. mongodb 超出内存限制

热门文章

  1. eclipse安装使用fat打jar包
  2. YII - 打印 SQL
  3. 北京大学Cousera学习笔记--2-计算导论与C语言基础-第一讲.计算机的基本原理-图灵机
  4. cocos2dx在win10系统上的VS2017运行时报错:丢失MSVCR110.dll
  5. Fiddler抓包【3】_设置断点修改
  6. archlinux中安装Oracle12c的过程中遇到的问题
  7. Visual Studio 2019 16.0 正式版下载
  8. 【JavaScript】常用的数据类型的处理方式
  9. 【论文速读】XiangBai_CVPR2018_Rotation-Sensitive Regression for Oriented Scene Text Detection
  10. day24--面向对象基础