当前位置: 首页 > 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.dnsts.com.cn/news/82492.html

相关文章:

  • 用模板建站郑州工程设计公司官网
  • 企业手机网站建设策划书西安关键词优化软件
  • 中山电商网站制作搭建网站的步骤
  • 商城网站带宽控制什么管理系统好做
  • 门户网站建设方案 ppt有什么做海报的网站吗
  • 网站上的销售怎么做的辽宁网站建设多少钱
  • 水处理设备网站建设商务定制网站
  • 网站动态设计效果seo排名软件有用吗
  • 调兵山网站网站建设的课程设计
  • 盘锦网站建设多少钱东莞市天气
  • 公司网站的服务器快速网站开发软件
  • 唐山网站制作方案网页制作文字素材
  • 刚做的网站在百度上搜不到自己做游戏需要学什么
  • 网站搭建流程青岛核酸检测最新消息
  • 太仓网站优化wordpress 过滤插件
  • 广安建设企业网站wordpress5.0.1
  • 网站合作建设方案做分析仪器推广的网站
  • 网站建设咨询公司地址server2008网站建设
  • 怎么做和美团一样的网站广州番禺职业技术学院官网
  • 中企动力做的电梯网站贵阳营销型网站建设
  • 如何制作简单的宣传片网站优化最为重要的内容是
  • 一个网站建设流程南昌做网站的公司有哪些
  • 免费个人手机网站手机网站制作哪家好
  • 开发一个网站多少钱冀icp 网站建设
  • 网站建设怎么建设青岛做网站服务商
  • 官方网站的推广策划怎么做婚纱摄影网站源码下载
  • 网站建设行业产业链分析宁波专业做网站的公司
  • 看优秀摄影做品的网站php 校园网站设计
  • 网站设计模板素材梦幻西游网页版官方网站
  • 智能优化网站领地网怎么编辑个人网站