weex之navigator封装为getPath.js

exports.getPath = function (pathWithoutSuffix, params) {
var path = '';
let platform = weex.config.env.platform;
let bundleUrl = weex.config.bundleUrl;

var exp = new RegExp(".+/");
var baseUrl = exp.exec(bundleUrl);

path = baseUrl;

if (platform.toLowerCase() === 'web') {
    path += pathWithoutSuffix + '.html'
}
else {
    path += pathWithoutSuffix + '.js'
}
if (params) {
    path += '?' + params
}

return path;

}

你可能感兴趣的:(weex之navigator封装为getPath.js)