ace-editor线上代码编辑器
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': '关键字'})
}
}
}
ace-editor线上代码编辑器的更多相关文章
- 如何利用Grunt生成对应的Source Map文件,线上代码压缩使用chrome浏览器便于调式
如何利用Grunt生成对应的Source Map文件,线上代码压缩使用chrome浏览器便于调式 首先我们来说说为何要生成sourceMap文件呢?简单的说,sourceMap是为了压缩后的代码调式提 ...
- Springboot拦截器线上代码失效
今天想测试下线上代码,能否正常的执行未登录的拦截.所以把拦截器的代码给开放出来,但是没想到线上代码addInerceptors(InterceptorRegistry registry) 这个方法一直 ...
- 不停机替换线上代码? 你没听错,Arthas它能做到
写在前边 有没有这样一种感受,自己写的代码在开发.测试环境跑的稳得一笔,可一到线上就抽风,不是缺这个就是少那个反正就是一顿报错,线上调试代码又很麻烦,让人头疼得很.阿里巴巴出了一款名叫Arthas的工 ...
- 如何用 fiddler 调试线上代码
有时代码上线了,突然就碰到了坑爹的错误.或者有时看别人家线上的代码,对于一个文件想 fork 下来试试效果又不想把全部文件拉到本地,都可以使用 fiddler 的线上调试功能. 比方说我们打开携程的首 ...
- 利用Chrome浏览器调试线上代码
前言 之前调试前端bug都是在开发环境中做完并多次测试没有问题之后发布测试环境,验收合格之后发布生产.但生产环境偏偏会有和开发和测试环境不一致的情况,例如测试环境需要加密,而开发环境先不加密,测试环境 ...
- git 获取线上代码并合并到本地
//查询当前远程的版本 $ git remote -v //获取最新代码到本地(本地当前分支为[branch],获取的远端的分支为[origin/branch]) $ git fetch origin ...
- git让线上代码强制覆盖本地的
git强制覆盖本地命令(分步执行): git fetch --all git reset --hard origin/master git pull git强制覆盖本地命令(单条执行): ...
- 前端通信:SSE设计方案(二)--- 服务器推送技术的实践以及一些应用场景的demo(包括在线及时聊天系统以及线上缓存更新,代码热修复案例)
距离上一篇博客,这篇文章的发布大概过了整整三个月.我也从饿了么度过了试用期,成为了正式员工.刚进来恰好遇到项目底层改造和迁移,将项目从angular全部迁移到vue上,所以适应这边的节奏和业务的开发任 ...
- 线上应用调试利器 --Arthas
在之前的文章中,我介绍了使用 Btrace 工具进行线上代码的debug (https://www.cnblogs.com/yougewe/p/10180483.html),其大致原理就是通过字节码注 ...
随机推荐
- 继承 & 多态 & 封装
什么是继承 继承是一种创建新类的方式,在python中,新建的类可以继承一个或多个父类,父类又可称为基类或超类,新建的类称为派生类或子类 python中类的继承分为:单继承和多继承 class Par ...
- mysql distinct()用法
在使用mysql时,有时需要查询出某个字段不重复的记录,虽然mysql提供有distinct这个关键字来过滤掉多余的重复记录只保留一条,但往往只用它来返回不重复记录的条数,而不是用它来返回不重记录的所 ...
- 【QT】qt python install pip
https://pip.pypa.io/en/stable/installing/ http://www.runoob.com/w3cnote/python-pip-install-usage.htm ...
- 干了这杯Java之HashMap
类: public class HashMap<K,V> extends AbstractMap<K,V> implements Map<K,V>, Cloneab ...
- ubuntu 16.04 搭建tigervnc
主要参考 https://vitux.com/ubuntu-vnc-server/ apt install xfce4 xfce4-goodies -yapt install -y tightvncs ...
- G面经Prepare: Longest All One Substring
give a string, all 1 or 0, we can flip a 0 to 1, find the longest 1 substring after the flipping 这是一 ...
- 2017UGUI之slider
不让鼠标控制slider的滑动: 鼠标之所以可以控制滑动是因为slider具有interactable这个属性(下图红色的箭头的地方):如果取消了这个属性的运行的时候就不能滑动了.如果要代码去控制这个 ...
- vue-cli@2的原理解析
作为一个菜鸟,我有一颗好奇的心,每当vue init 的时候,看到那流畅的进度和神奇的结果,心里都充满一窥其本质的期望…… 以下就是我不断的console,大致理出来的一个流程心得,纪录在此,以作备忘 ...
- Unity3d中角色模型和角色名字保持相对位置
3D游戏中,经常遇到这样的情况.角色模型上需要显示角色名字或者血条等信息. 如果用一个摄像机会有可能出现名字或血条显示不正常等问题,所以我采用两个摄像机.一个渲染名字或血条等UI,另一个渲染角色模型. ...
- SQL死锁操作
这两天数据库经常被锁,所以记录一下操作: 查看被锁表:select request_session_id spid,OBJECT_NAME(resource_associated_entity_id) ...