From 17438df5da4d49a9f225d88904fbf224b208b50f Mon Sep 17 00:00:00 2001 From: sxh <1632740646@qq.com> Date: Fri, 22 Apr 2022 16:33:33 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=84=E5=88=99=E5=BC=95=E6=93=8E=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=E9=94=99=E8=AF=AF=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vue/src/components/Codemirror/index.vue | 22 ++++++++++++++-------- vue/src/views/iot/emqx/rule.vue | 4 ++-- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/vue/src/components/Codemirror/index.vue b/vue/src/components/Codemirror/index.vue index 3dcd2e50..06d2d8fa 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 67146f4c..be132257 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: - + 测 试