vue代码编辑器组件_vue activiti
大家好,又见面了,我是你们的朋友全栈君。
vue-monaco-editor
Monaco Editor Vue Component
Based off React Monaco Editor
Setup
npm install vue-monaco-editor –save
Simple Vue Use
import MonacoEditor from ‘vue-monaco-editor’
// use in component
export default {
components: {
MonacoEditor
}
}
Component Props
Option | Type | Default | Description |
---|---|---|---|
language | String | javascript | |
height | Number/String | 100% | |
width | Number/String | 100% | |
code | String | // code \n | Initial code to show |
theme | String | vs-dark | vs, hc-black, or vs-dark |
highlighted | Array[Object] | [{ number: 0, class: ''}] | Lines to highlight with numbers and .classes |
changeThrottle | Number(ms) | 0 | throttle codeChange emit |
srcPath | String | "" | see Webpack Use below |
editorOptions | Object | Merged with defaults below | See Monaco Editor Options |
Editor Default Options
defaults: {
selectOnLineNumbers: true,
roundedSelection: false,
readOnly: false,
cursorStyle: ‘line’,
automaticLayout: false,
glyphMargin: true
}
Component Events
These events are available to parent component
Event | Returns | Description |
---|---|---|
mounted | editor[editor instance] | Emitted when editor has mounted |
codeChange | editor[editor instance] | Emitted when code has changed |
Example
Component Implementation
<MonacoEditor
height=”600″
language=”typescript”
:code=”code”
:editorOptions=”options”
@mounted=”onMounted”
@codeChange=”onCodeChange”
>
</MonacoEditor>
Parent
module.exports = {
components: {
Monaco
},
data() {
return {
code: ‘// Type away! \n’,
options: {
selectOnLineNumbers: false
}
};
},
methods: {
onMounted(editor) {
this.editor = editor;
},
onCodeChange(editor) {
console.log(this.editor.getValue());
}
}
};
Webpack Use
By default, monaco-editor is loaded from a cdn asyncronously using require
. To use a local copy of monaco-editor
with webpack, we need to expose the dependency in our build directory:
npm install copy-webpack-plugin --save-dev
Add this to your webpack.config.js:
const CopyWebpackPlugin = require(‘copy-webpack-plugin’);
module.exports = {
plugins: [
new CopyWebpackPlugin([
{
from: ‘node_modules/monaco-editor/min/vs’,
to: ‘vs’,
}
])
]
};
Then, specify the build directory path in the srcPath
prop. See src/App.vue
for an example.
Dev Use
git clone [this repo] .
npm install
npm run dev
Edit src/App.vue
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/170428.html原文链接:https://javaforall.cn
相关文章
- vue+mongodb_mongodb查询速度
- Vue专题 02_计算属性(computed) VS 方法(methods)
- vue集成海康h5player实现播放
- Vue的引入与基本使用
- 一篇带你从小白到入门的vue教程
- Vue中显示img图片,显示不出来怎么办?vue显示图片
- Vue笔记(10) vue-router
- 一篇把vue准备工作说的明明白白的(奶妈级教程)
- vue面试常见考察点总结
- Vue学习笔记之vue.js 两个等号 == 和三个等号===的区别 数字0和空字符串
- 在网页文档中引入Vue.js的方法有哪些?_vue直接引入js文件没有用
- 前端一面经典vue面试题总结
- VUE组件封装_vue使用组件
- vue生成二维码并保存图片_vue实现扫描二维码
- vue 调用子组件方法失败_Vue子组件调用父组件的方法及常见问题「建议收藏」
- Vue项目:菜农管理 【maven + spring boot + RESTFul + SSM+vue + axios】
- 【架构师(第三十篇)】Vue-Test-Utils 全局组件和第三方库 vuex | vue-router
- ruoyi-vue版本框架(二)源码目录结构的讲解,与底层子项目的讲解
- 4. 「vue@2.6.11 源码分析」new Vue() 整体流程和组件渲染之前的准备工作
- vue+echarts实现疫情折线图
- 开心档-软件开发入门之Vue.js Ajax(vue-resource)
- Vue2.0 搭建Vue脚手架(vue-cli)详解编程语言
- 使用Vue框架使用MSSQL数据库实现快速开发(vue mssql)
- Vue如何连接Redis数据库(vue怎么连接Redis)
- Vue如何利用Redis加速应用程序性能(vue如何使用redis)
- 优化网站性能,Vue搭配Redis缓存更加有效(vue使用redis缓存)