diff --git a/vue/src/components/Codemirror/index.vue b/vue/src/components/Codemirror/index.vue index 3dcd2e5021d19c935551e20814129e5937580a1d..06d2d8fa15e82d6f8d2c460922cec51ab962b6dd 100644 --- a/vue/src/components/Codemirror/index.vue +++ b/vue/src/components/Codemirror/index.vue @@ -38,10 +38,7 @@ import "codemirror/addon/lint/lint.js"; export default { props: { - value: { - type: String, - required: true, - }, + value: '', height: { type: String, required: true, @@ -60,7 +57,11 @@ export default { value(value) { const editorValue = this.editor.getValue(); if (value !== editorValue) { - this.editor.setValue(this.value); + if (typeof this.value !== "undefined") { + this.editor.setValue(this.value); + } else { + this.editor.setValue(""); + } } }, }, @@ -74,7 +75,7 @@ export default { gutters: [ "CodeMirror-linenumbers", "CodeMirror-foldgutter", - "CodeMirror-lint-markers", // CodeMirror-lint-markers是实现语法报错功能 + "CodeMirror-lint-markers", // CodeMirror-lint-markers是实现语法报错功能 ], lint: true, //lineWrapping: true, // 自动换行 @@ -82,14 +83,19 @@ export default { autoCloseBrackets: true, // 输入和退格时成对 readOnly: false, // 只读 foldGutter: true, - autoRefresh: true + autoRefresh: true, }); //代码自动提示功能,记住使用cursorActivity事件不要使用change事件,这是一个坑,那样页面直接会卡死 this.editor.on("inputRead", () => { this.editor.showHint(); }); + debugger; this.editor.setSize("auto", this.height); - this.editor.setValue(this.value); + if (typeof this.value !== "undefined") { + this.editor.setValue(this.value); + } else { + this.editor.setValue(""); + } }, methods: { getValue() { diff --git a/vue/src/views/iot/emqx/rule.vue b/vue/src/views/iot/emqx/rule.vue index 67146f4c542d37723326966cef3bfee6436b91f2..be1322577cbede8546360278ac93bd443d4fd3b9 100644 --- a/vue/src/views/iot/emqx/rule.vue +++ b/vue/src/views/iot/emqx/rule.vue @@ -48,7 +48,7 @@ - +
@@ -155,7 +155,7 @@ payload: - + 测 试