知识点

1. js驼峰与下划线相互转化

// 下划线转换驼峰

function toHump(name) {
    return name.replace(/\_(\w)/g, function(all, letter){
        return letter.toUpperCase();
    });
}

// 驼峰转换下划线

function toLine(name) {
  return name.replace(/([A-Z])/g,"_$1").toLowerCase();
  }

2.导出表格

    // 导出表格
    exportExcel () {
      let url = `${baseUrl}/admin_web/export_data_project_report`;
      if (this.queryInfo.project) url = url + "?project_name=" + this.queryInfo.project;
      if (this.queryInfo.date) url = url + "&start_time=" + this.queryInfo.date[0] + "&end_time=" + 				             this.queryInfo.date[1];
      window.open(url, '_blank')
    }
 // window.open(this.indexro,'_blank') // 在新窗口打开外链接
 // window.location.href =this.indexro;  //在本页面打开外部链接

3. 控制子组件的显示与隐藏

  computed: {
    groupRolesDialogVisible: {
      get () {
        return this.rolesDialogVisible;
      },
      set (val) {
        this.$emit('update:rolesDialogVisible', val);
      },
    },
  },

4.截取字符串

id = row.url.substring(row.url.indexOf('=') + 1, row.url.length);

5.Promise.all的用法

    initCreateEnv () {
      let templateId = this.$route.query.templateId;
      if (!Array.isArray(templateId)) {
        templateId = [templateId];
      }
      const list = [];
      templateId.forEach(tplId => {
        list.push(initCreateEnv(tplId));
      })
      Promise.all(list).then(res => {
        if (res.length > 0) {
          this.templateList = [...res];
          this.userInfo = res[0].userInfo;
        }
      }, (err) => {
        this.$message({
          type: 'error',
          message: err.errmsg,
        });
        console.error(err);
      })
    },

6. 时间转换

import moment from 'moment'

moment(time).format('YYYY-MM-DD');
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值