增加CodeMirror组件

This commit is contained in:
virusdefender
2016-08-14 19:06:50 +08:00
parent 39fa2872a0
commit b5f189d352
2 changed files with 392 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
<template>
<textarea id="{{ editorId }}"></textarea>
</template>
<script>
import CodeMirror from "codemirror"
import "codemirror/mode/javascript/javascript"
import "codemirror/mode/python/python"
export default({
data() {
return {
editor: {},
editorId: Math.random().toString(36).substr(2),
language: "python"
}
},
attached() {
CodeMirror.fromTextArea(document.getElementById(this.editorId), {
lineNumbers: true,
mode: this.language,
indentUnit: 4,
matchBrackets: true
});
}
})
</script>
<style>
@import "../../../../static/css/CodeMirror.css";
.CodeMirror {
min-height: 250px;
_height: 250px;
height: auto;
}
.CodeMirror-scroll {
overflow: auto;
min-height: 250px;
height: auto;
position: relative;
outline: none;
}
</style>