js传递参数中包含+号时的处理方法

encodeURI(url).replace(/\+/g, '%2B')

例子:

$scope.getAnesthesiawaystatistical = function (annual, anesthesiaMethodRep) {
var Anesthesiurl = "/api/v1/AnesthesiAwayStatistical/GetAnesthesiAwayStatisticalCount?anesthesiaMethodRep=" + "'" + anesthesiaMethodRep + "'" + "&annual=" + annual;
alert(encodeURI(Anesthesiurl).replace(/\+/g, '%2B'));
$http.get(encodeURI(Anesthesiurl).replace(/\+/g, '%2B')).success(function (data) {

if (data.has_val) {
$scope.AnesthesiAwayStatisticalList = data.result;

console.log($scope.AnesthesiAwayStatisticalList);
}
});
}

上一篇:SDOI2017硬币游戏


下一篇:python @property的用法及含义全面解析