2021-12-15

b标题表达式

  // 表达式

  expression(titleData, config, currentFullParmas) {

    let a = titleData.value; // 输入的内容

    let res = titleData.value;

    let reg = /\{(.*?)\}/gi;

    let tmp = a.match(reg);

    // 有匹配

    if (tmp) {

      let b = '';

      let arr = [];

      for (let i = 0; i < tmp.length; i++) {

        b = tmp[i].replace(reg, '$1');

        arr.push(tmp[i]);

      }

      let title = a;

      if (currentFullParmas && b in currentFullParmas) {

        arr.forEach(i => {

          title = title.replace(new RegExp(i, 'gm'), currentFullParmas[b]);

        });

        res = title;

        let info = config.value.chooseValue.value;

        if (currentFullParmas && info in currentFullParmas) {

          let isEnum = config.value.chooseValue.values.enum;

          // 判断是否枚举类型

          if (isEnum) {

            let data = config.value.data;

            if (data.length !== 0) {

              data.forEach((item, index) => {

                if (item.value === currentFullParmas[info]) {

                  res = data[index].description;

                }

              });

            }

          }

        }

      } else {

        res = title;

      }

    }

    return res;

  },

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • ECMAScript - 学习笔记 🎬 🧩nvm node.js 包管理工具 nvm github[https:/...
    Super三脚猫阅读 648评论 0 1
  • 变量 var 声明变量没有块级作用域可以重复声明不能限制 let 声明变量支持块级作用域禁止重复声明 con...
    5jing阅读 963评论 0 1
  • 一、初识jQuery.js jQuery.js是一款优秀的JS类库,其本质就是在一个立即执行的匿名函数中的闭包,j...
    刘远舟阅读 648评论 1 0
  • 原文链接:http://www.jianshu.com/p/2a9367afe9e7 1510997059(1)....
    悬笔e绝阅读 5,538评论 0 0
  • https://blog.csdn.net/feiyunjs/article/details/94722766 /...
    FsdSoyu阅读 1,015评论 0 0