JavaScript中如何设置一个基础路径变量(basePath)呢?
- 内容介绍
- 文章标签
- 相关推荐
本文共计135个文字,预计阅读时间需要1分钟。
主要用来替代jsp中经常使用的basePath+/**/来减少相对路径,而增加basePath*+*项目上下文访问路径+*/*。例如:/myproject/*。
/*
* 减少相对路径而添加的basePath
* 主要用来替代jsp中经常使用的basePath
* */
/**
* 项目上下文访问路径
* 如:/myproject
* @type {string}
*/
var projectPath = window.location.pathname == 'null'?'':window.location.pathname.substring(0,window.location.pathname.indexOf('/',1));
/**
* 服务器地址 如 : localhost:8080
* @type {string|Array|*|string|Array.
本文共计135个文字,预计阅读时间需要1分钟。
主要用来替代jsp中经常使用的basePath+/**/来减少相对路径,而增加basePath*+*项目上下文访问路径+*/*。例如:/myproject/*。
/*
* 减少相对路径而添加的basePath
* 主要用来替代jsp中经常使用的basePath
* */
/**
* 项目上下文访问路径
* 如:/myproject
* @type {string}
*/
var projectPath = window.location.pathname == 'null'?'':window.location.pathname.substring(0,window.location.pathname.indexOf('/',1));
/**
* 服务器地址 如 : localhost:8080
* @type {string|Array|*|string|Array.

