项目杂记一
把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; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |