当前位置: 首页 > news >正文

睿达科网络 网站建设四川省安监站网址

睿达科网络 网站建设,四川省安监站网址,网站 宗旨,免费的个人简历模板在哪找效果图 安装codemirror依赖 本示例为Vue2项目#xff0c;安装低版本的依赖 npm i codemirror5.65.12 npm i vue-codemirror4.0.6 实现 实现代码如下#xff0c;里边涉及到的变量和函数自行替换即可#xff0c;没有其他复杂逻辑。 templatediv classp…效果图 安装codemirror依赖 本示例为Vue2项目安装低版本的依赖 npm i codemirror5.65.12 npm i vue-codemirror4.0.6 实现 实现代码如下里边涉及到的变量和函数自行替换即可没有其他复杂逻辑。 templatediv classpickerdiv classcode-editdiv classtop-title公式/divcodemirrorrefcodeEditorv-modelformulaStr:optionscmOptionsinputcodeMirrorChange/codemirror/divel-buttonsizeminiiconel-icon-settingclickinsertContent(表单4, variable)添加变量/el-buttonel-buttonsizeminiiconel-icon-settingclickinsertContent(SUM, func)添加函数/el-button/div/templatescript import {codemirror} from vue-codemirror; import codemirror/lib/codemirror.css; import codemirror/theme/idea.css;export default {components: {codemirror},data() {return {cmOptions: {// 语言及语法模式mode: text/javascript,// 主题theme: idea,// 显示函数line: true,lineNumbers: false,// 软换行lineWrapping: true,// tab宽度tabSize: 4,},lang: javascript,formulaStr: 表单 表单1 * 表单11*表单12SUM(1,2) AVG(99,21) IF(),};},computed: {editor() {return this.$refs.codeEditor.codemirror;}},mounted() {this.focus(this.formulaStr)this.autoMarkText()},methods: {codeMirrorChange() {//获取 editor 的内容console.log(content1: this.formulaStr);console.log(content2: JSON.stringify(this.editor.getValue()));},addFormula(content, type) {this.insertContent(content, type)},/*** editor 中的对内容进行处理* param value* param type variable | funcvariable为表单变量需标记func 为函数也需要做标记*/insertContent(value, type) {const from this.editor.getCursor();if (type variable) {this.editor.replaceSelection(value);const to this.editor.getCursor();this.markText(from, to, value, cm-field);} else if (type func) {this.editor.replaceSelection(${value}());const to this.editor.getCursor();this.markText(from, {line: to.line, ch: to.ch - 2}, value, cm-func);this.editor.setCursor({line: to.line, ch: to.ch - 1});} else if (typeof value string) {this.editor.replaceSelection(value);}this.editor.focus();},autoMarkText() {if (this.formulaStr) {this.autoMark(this.formulaStr);this.focus(this.formulaStr);}},focus(value) {this.editor.setCursor({line: 0,ch: value ? value.length : 0});this.editor.focus()},markText(from, to, label, className) {if (className void 0) {className cm-func;}let text document.createElement(span);text.className className;text.innerText label;this.editor.markText(from, to, {atomic: true,replacedWith: text,});},/*** 解析 editor 的内容分别对表单变量和函数进行标记*/autoMark() {const editor this.editor;const lines editor.lineCount();for (let line 0; line lines; line) {const content editor.getLine(line);// 标记函数调用,匹配一个或多个连续的大写字母后面可以有任意数量的空白字符再紧跟一个左括号content.replace(/([A-Z])\s*\(/g, (_, func, pos) {this.markText({line: line, ch: pos}, {line: line, ch: pos func.length}, func, cm-func);return _;});// 标记表单变量,这应该是动态获取自行替换即可let vars [表单, 表单1, 表单11, 表单12];vars.forEach(v {let from 0;let idx -1;while (~(idx content.indexOf(v, from))) {this.markText({line: line, ch: idx}, {line: line, ch: idx v.length}, v, cm-field);from idx v.length;}});}},}, }; /scriptstyle langless scoped .picker {height: 525px;text-align: left;width: 50%;margin: 0 auto;.code-edit {height: 240px;border-radius: 6px;border: 1px solid #e8e9eb;} } .top-title {background-color: #fafafa;height: 30px;vertical-align: center;line-height: 30px;padding-left: 10px;border-radius: 4px 4px 0 0;border-bottom: none; } /deep/ .CodeMirror {height: 200px !important;/*表单变量样式*/.cm-field {background: #007bff;padding: 3px 5px;border-radius: 3px;color: #fff;margin: 0 1px;}/*函数样式*/.cm-func {font-weight: bold;color: #ae4597;line-height: 14px;margin: 0 1px;padding: 0 2px;}.CodeMirror-scroll {width: 100%;} }/style
http://www.w-s-a.com/news/77929/

相关文章:

  • 鄂州官方网站食品网站建设需求分析
  • 福州网站建设金森要做好网络营销首先要
  • 中山哪里有好网站建设公司企业培训考试平台下载
  • 域名备案查询 网站备案查询企业网站建设问题研究
  • wordpress无法编辑北京优化网站方法
  • 公司建设一个网站最好的网站建设哪家好
  • 南京市住宅建设总公司网站wordpress 自己写的网页
  • 淄博网站制作企业高端长沙企业网站制作服务报价
  • 网站服务理念中外商贸网站建设
  • 如何自己建立网站中国建设银行网站忘记密码
  • 什么是a站如何在12366网站上做实名认证
  • 斗蟋蟀网站建设谭谭心怎么建设网站
  • 优秀网站开发商郑州网站建设套餐
  • 做伤残鉴约号网站购物网站建设新闻
  • 黄江网站建设公司自己房子做民宿挂什么网站
  • 手游网站做cpc还是cpm广告号宣武郑州阳网站建设
  • vs连接数据库做网站建立网站
  • 电商网站设计图片素材p2p网站建设石家庄
  • 莲塘网站建设如何文字推广一个婚恋网站
  • 医院网站建设工作汇报WordPress不发邮件了
  • 怎么做外语网站个人网页设计作品ps
  • 网站原型怎么做vps如何建两个网站
  • 商城网站建设源码嘉兴seo计费管理
  • 城乡建设网站证件查询系统wordpress 时间代码
  • php网站建设 关键技术做网站哪家正规
  • 网站开发用什么写得比较好谷歌的英文网站
  • 青岛网站建设公司在哪vivo手机商城
  • 兼职刷客在哪个网站做哪个网站做淘宝客
  • 眼科医院网站开发网络营销特点是什么
  • 提交网站给百度增加wordpress插件