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);
}
});
}

原文地址:https://www.cnblogs.com/zhangxiaolei521/p/6208491.html