加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

项目杂记一

发布时间:2020-12-14 01:12:59 所属栏目:百科 来源:网络整理
导读:把webappbuilder自动生成的env.js拷贝到VS项目文件夹中,需要注意代码替换。 主要是对正则表达式和js的两个方法的理解。 pop()方法:JS中pop()方法用于删除并返回数组的最后一个元素。 test()方法:用于检测字符串是否匹配某个模式。 所以要把以下代码 funct

把webappbuilder自动生成的env.js拷贝到VS项目文件夹中,需要注意代码替换。

主要是对正则表达式和js的两个方法的理解。

pop()方法:JS中pop()方法用于删除并返回数组的最后一个元素。

test()方法:用于检测字符串是否匹配某个模式。


所以要把以下代码

function getPath() {
  var fullPath,path;

  fullPath = window.location.pathname;
  if (fullPath === '/' || fullPath.substr(fullPath.length - 1) === '/') {
    path = fullPath;
  } else if (/.html$/.test(fullPath.split('/').pop())) {
    var sections = fullPath.split('/');
    sections.pop();
    path = sections.join('/') + '/';
  } else {
    return false;
  }
  return path;
}

替换成

function getPath() { var fullPath,path; fullPath = window.location.pathname; alert("你好"); if (fullPath === '/' || fullPath.substr(fullPath.length - 1) === '/') { path = fullPath; } // pop() 方法用于删除并返回数组的最后一个元素。 else if (/.aspx$/.test(fullPath.split('/').pop())) { var sections = fullPath.split('/'); sections.pop(); path = sections.join('/') + '/'; } else { return false; } return path; }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读