代码自动补全

develop
jialong.yu 3 years ago
parent e48147db7b
commit 1c93ae2793
  1. 21
      src/components/codemirror.vue

@ -6,7 +6,7 @@
:options="cmOption"
class="code-mirror"
@ready="ready"
ref="myCmGenerate"
ref="codemirror"
></codemirror>
<div v-if="isSubmit" class="code-mask"></div>
<el-button
@ -49,6 +49,7 @@ import newmain from "../util/newMain";
import { codemirror } from "vue-codemirror";
import "codemirror/theme/ambiance.css"; //
import "codemirror/mode/javascript/javascript.js";
import "codemirror/mode/python/python.js";
import "codemirror/lib/codemirror.css";
// require active-line.js
import "codemirror/addon/selection/active-line.js";
@ -119,12 +120,10 @@ export default {
foldGutter: true, //
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
highlightSelectionMatches: { showToken: /\w/, annotateScrollbar: true }, //
mode: {
// , codemirror/mode
name: "javascript",
json: true
},
mode: 'python',
lineWrapping: true, //
autoCloseTags: true,//
autoCloseBrackets: true,//
// hint.js options
hintOptions: {
//
@ -134,8 +133,7 @@ export default {
keyMap: "sublime",
matchBrackets: true,
showCursorWhenSelecting: true,
theme: "monokai", //
extraKeys: { Ctrl: "autocomplete" } // keyMap
theme: "monokai" //
},
inputTextReg: /^((?!#).*?(,|\(|\[|\{|\s)+)?input(?!\w)\(['|"]([\s\S]+?)['|"]\)/m, // input()
requestList: [], // inputaxios
@ -162,7 +160,12 @@ export default {
methods: {
//
ready() {
this.$refs.myCmGenerate.codemirror.setSize("auto", "calc(100vh - 167px)");
const code = this.$refs.codemirror.codemirror
code.setSize("auto", "calc(100vh - 167px)");
code.on('keypress', function() {
//
code.showHint()
});
},
/**
* python代码里如果有input函数的话是做了单独的处理的原理是先把所有input函数都替换成exit函数再在exit函数里加上特定标识再通过接口传给后端去执行

Loading…
Cancel
Save