react-web-router-flux
Version:
adapter react native-router-flux for web
33 lines (30 loc) • 817 B
JSX
/**
* 名称:辅助工具
* 日期:2016-12-13
* 作者:Beven
* 描述:无
*/
export default class RouteUtility {
//驼峰命名
static nameJoin(key, parentKey) {
if (key && parentKey) {
return parentKey + key[0].toUpperCase() + key.substring(1);
} else if (key) {
return key;
} else {
return parentKey;
}
}
/**
* 将指定url的动态值使用props的属性值替换,生成一个实际的url
* @param url {String} 模板url
* @param props {Object} url模板变量值
*/
static param(url, props) {
let keys = Object.keys(props);
for (let key of keys) {
url = url.replace(`:${key}`, props[key]);
}
return url;
}
}